\input{preamble}

% OK, start here.
%
\begin{document}

\title{Duality for Schemes}


\maketitle

\phantomsection
\label{section-phantom}

\tableofcontents

\section{Introduction}
\label{section-introduction}

\noindent
This chapter studies relative duality for morphisms of schemes
and the dualizing complex on a scheme. A reference is \cite{RD}.

\medskip\noindent
Dualizing complexes for Noetherian rings were defined and studied in
Dualizing Complexes, Section \ref{dualizing-section-dualizing} ff.
In this chapter we continue this by studying dualizing complexes on
schemes, see Section \ref{section-dualizing-schemes}.

\medskip\noindent
The bulk of this chapter is devoted to studying the right adjoint
of pushforward in the setting of derived categories of sheaves
of modules with quasi-coherent cohomology sheaves.
See Sections
\ref{section-twisted-inverse-image},
\ref{section-restriction-to-opens},
\ref{section-base-change-map},
\ref{section-base-change-II},
\ref{section-trace},
\ref{section-compare-with-pullback},
\ref{section-sections-with-exact-support},
\ref{section-duality-finite},
\ref{section-perfect-proper},
\ref{section-dualizing-Cartier}, and
\ref{section-examples}.
Here we follow the papers 
\cite{Neeman-Grothendieck}, \cite{LN},
\cite{Lipman-notes}, and \cite{Neeman-improvement}.

\medskip\noindent
We discuss the important and useful upper shriek functors $f^!$ for
separated morphisms of finite type between Noetherian schemes in
Sections \ref{section-upper-shriek},
\ref{section-upper-shriek-properties}, and
\ref{section-base-change-shriek}
culminating in the overview Section
\ref{section-duality}.

\medskip\noindent
In Section \ref{section-glue}
we explain alternative theory of duality and dualizing
complexes when working over a fixed locally Noetherian
base endowed with a dualizing complex (this section corresponds
to a remark in Hartshorne's book).

\medskip\noindent
In the remaining sections we give a few applications.

\medskip\noindent
This chapter is continued by the chapter on duality
on algebraic spaces, see
Duality for Spaces, Section \ref{spaces-duality-section-introduction}.







\section{Dualizing complexes on schemes}
\label{section-dualizing-schemes}

\noindent
We define a dualizing complex on a locally Noetherian scheme
to be a complex which affine locally comes from a dualizing
complex on the corresponding ring. This is not completely
standard but agrees with all definitions in the literature
on Noetherian schemes of finite dimension.

\begin{lemma}
\label{lemma-equivalent-definitions}
Let $X$ be a locally Noetherian scheme. Let $K$ be an object of
$D(\mathcal{O}_X)$. The following are equivalent
\begin{enumerate}
\item For every affine open $U = \Spec(A) \subset X$ there exists
a dualizing complex $\omega_A^\bullet$ for $A$ such that
$K|_U$ is isomorphic to the image of $\omega_A^\bullet$ by
the functor $\widetilde{} : D(A) \to D(\mathcal{O}_U)$.
\item There is an affine open covering $X = \bigcup U_i$, $U_i = \Spec(A_i)$
such that for each $i$ there exists a dualizing complex $\omega_i^\bullet$ for
$A_i$ such that $K|_{U_i}$ is isomorphic to the image of $\omega_i^\bullet$ by
the functor $\widetilde{} : D(A_i) \to D(\mathcal{O}_{U_i})$.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume (2) and let $U = \Spec(A)$ be an affine open of $X$.
Since condition (2) implies that $K$ is in $D_\QCoh(\mathcal{O}_X)$
we find an object $\omega_A^\bullet$ in $D(A)$ whose associated
complex of quasi-coherent sheaves is isomorphic to $K|_U$, see
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-compare-bounded}.
We will show that $\omega_A^\bullet$ is a dualizing complex for $A$
which will finish the proof.

\medskip\noindent
Since $X = \bigcup U_i$ is an open covering, we can find a standard
open covering $U = D(f_1) \cup \ldots \cup D(f_m)$ such that
each $D(f_j)$ is a standard open in one of the affine opens $U_i$, see
Schemes, Lemma \ref{schemes-lemma-standard-open-two-affines}.
Say $D(f_j) = D(g_j)$ for $g_j \in A_{i_j}$.
Then $A_{f_j} \cong (A_{i_j})_{g_j}$ and we have
$$
(\omega_A^\bullet)_{f_j} \cong (\omega_i^\bullet)_{g_j}
$$
in the derived category by
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-compare-bounded}.
By Dualizing Complexes, Lemma \ref{dualizing-lemma-dualizing-localize}
we find that
the complex $(\omega_A^\bullet)_{f_j}$ is a dualizing complex over
$A_{f_j}$ for $j = 1, \ldots, m$. This implies that $\omega_A^\bullet$
is dualizing by
Dualizing Complexes, Lemma \ref{dualizing-lemma-dualizing-glue}.
\end{proof}

\begin{definition}
\label{definition-dualizing-scheme}
Let $X$ be a locally Noetherian scheme. An object $K$ of
$D(\mathcal{O}_X)$ is called a {\it dualizing complex} if
$K$ satisfies the equivalent conditions of
Lemma \ref{lemma-equivalent-definitions}.
\end{definition}

\noindent
Please see remarks made at the beginning of this section.

\begin{lemma}
\label{lemma-affine-duality}
Let $A$ be a Noetherian ring and let $X = \Spec(A)$. Let $K, L$ be objects
of $D(A)$. If $K \in D_{\textit{Coh}}(A)$ and $L$ has finite injective
dimension, then
$$
R\SheafHom_{\mathcal{O}_X}(\widetilde{K}, \widetilde{L})
=
\widetilde{R\Hom_A(K, L)}
$$
in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
We may assume that $L$ is given by a finite complex $I^\bullet$
of injective $A$-modules. By induction on the length of $I^\bullet$
and compatibility of the constructions with distinguished triangles,
we reduce to the case that $L = I[0]$ where $I$ is an injective $A$-module.
In this case, Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-internal-hom}, tells us that
the $n$th cohomology sheaf of
$R\SheafHom_{\mathcal{O}_X}(\widetilde{K}, \widetilde{L})$
is the sheaf associated to the presheaf
$$
D(f) \longmapsto \Ext^n_{A_f}(K \otimes_A A_f, I \otimes_A A_f)
$$
Since $A$ is Noetherian, the $A_f$-module $I \otimes_A A_f$ is injective
(Dualizing Complexes, Lemma
\ref{dualizing-lemma-localization-injective-modules}). Hence we see that
\begin{align*}
\Ext^n_{A_f}(K \otimes_A A_f, I \otimes_A A_f)
& =
\Hom_{A_f}(H^{-n}(K \otimes_A A_f), I \otimes_A A_f) \\
& =
\Hom_{A_f}(H^{-n}(K) \otimes_A A_f, I \otimes_A A_f) \\
& =
\Hom_A(H^{-n}(K), I) \otimes_A A_f
\end{align*}
The last equality because $H^{-n}(K)$ is a finite $A$-module, see
Algebra, Lemma \ref{algebra-lemma-hom-from-finitely-presented}.
This proves that the canonical map
$$
\widetilde{R\Hom_A(K, L)}
\longrightarrow
R\SheafHom_{\mathcal{O}_X}(\widetilde{K}, \widetilde{L})
$$
is a quasi-isomorphism in this case and the proof is done.
\end{proof}

\begin{lemma}
\label{lemma-internal-hom-evaluate-isom}
Let $X$ be a Noetherian scheme. Let $K, L, M \in D_\QCoh(\mathcal{O}_X)$. 
Then the map
$$
R\SheafHom(L, M) \otimes_{\mathcal{O}_X}^\mathbf{L} K
\longrightarrow
R\SheafHom(R\SheafHom(K, L), M)
$$
of Cohomology, Lemma \ref{cohomology-lemma-internal-hom-evaluate}
is an isomorphism in the following two cases
\begin{enumerate}
\item $K \in D^-_{\textit{Coh}}(\mathcal{O}_X)$,
$L \in D^+_{\textit{Coh}}(\mathcal{O}_X)$, and $M$ affine locally has
finite injective dimension (see proof), or
\item $K$ and $L$ are in $D_{\textit{Coh}}(\mathcal{O}_X)$,
the object $R\SheafHom(L, M)$ has finite tor dimension, and
$L$ and $M$ affine locally have finite injective dimension
(in particular $L$ and $M$ are bounded).
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). We say $M$ has affine locally finite injective dimension
if $X$ has an open covering by affines $U = \Spec(A)$ such that the object
of $D(A)$ corresponding to $M|_U$ (Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-compare-bounded})
has finite injective dimension\footnote{This condition is independent of the
choice of the affine open cover of the Noetherian scheme $X$.
Details omitted.}. To prove the lemma we may
replace $X$ by $U$, i.e., we may assume $X = \Spec(A)$
for some Noetherian ring $A$. Observe that
$R\SheafHom(K, L)$ is in $D^+_{\textit{Coh}}(\mathcal{O}_X)$ by
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-coherent-internal-hom}.
Moreover, the formation of the left and right hand side
of the arrow commutes with the functor $D(A) \to D_\QCoh(\mathcal{O}_X)$ by
Lemma \ref{lemma-affine-duality} and
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-internal-hom}
(to be sure this uses the assumptions on $K$, $L$, $M$ and what we just
proved about $R\SheafHom(K, L)$).
Then finally the arrow is an isomorphism by
More on Algebra, Lemmas
\ref{more-algebra-lemma-internal-hom-evaluate-isomorphism} part (2).

\medskip\noindent
Proof of (2). We argue as above. A small change is that here we get
$R\SheafHom(K, L)$ in $D_{\textit{Coh}}(\mathcal{O}_X)$ because
affine locally (which is allowable by Lemma \ref{lemma-affine-duality})
we may appeal to Dualizing Complexes, Lemma
\ref{dualizing-lemma-finite-ext-into-bounded-injective}.
Then we finally conclude by
More on Algebra, Lemma
\ref{more-algebra-lemma-internal-hom-evaluate-isomorphism-technical}.
\end{proof}

\begin{lemma}
\label{lemma-dualizing-schemes}
Let $K$ be a dualizing complex on a locally Noetherian scheme $X$.
Then $K$ is an object of $D_{\textit{Coh}}(\mathcal{O}_X)$
and $D = R\SheafHom_{\mathcal{O}_X}(-, K)$ induces an anti-equivalence
$$
D :
D_{\textit{Coh}}(\mathcal{O}_X)
\longrightarrow
D_{\textit{Coh}}(\mathcal{O}_X)
$$
which comes equipped with a canonical isomorphism
$\text{id} \to D \circ D$. If $X$ is quasi-compact, then
$D$ exchanges $D^+_{\textit{Coh}}(\mathcal{O}_X)$ and
$D^-_{\textit{Coh}}(\mathcal{O}_X)$ and induces an anti-equivalence
$D^b_{\textit{Coh}}(\mathcal{O}_X) \to D^b_{\textit{Coh}}(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Let $U \subset X$ be an affine open. Say $U = \Spec(A)$ and
let $\omega_A^\bullet$ be a dualizing complex for $A$
corresponding to $K|_U$
as in Lemma \ref{lemma-equivalent-definitions}.
By Lemma \ref{lemma-affine-duality} the diagram
$$
\xymatrix{
D_{\textit{Coh}}(A) \ar[r] \ar[d]_{R\Hom_A(-, \omega_A^\bullet)} &
D_{\textit{Coh}}(\mathcal{O}_U) \ar[d]^{R\SheafHom_{\mathcal{O}_X}(-, K|_U)} \\
D_{\textit{Coh}}(A) \ar[r] &
D(\mathcal{O}_U)
}
$$
commutes. We conclude that $D$ sends $D_{\textit{Coh}}(\mathcal{O}_X)$ into
$D_{\textit{Coh}}(\mathcal{O}_X)$. Moreover, the canonical map
$$
L
\longrightarrow
R\SheafHom_{\mathcal{O}_X}(K, K) \otimes_{\mathcal{O}_X}^\mathbf{L} L
\longrightarrow
R\SheafHom_{\mathcal{O}_X}(R\SheafHom_{\mathcal{O}_X}(L, K), K)
$$
(using Cohomology, Lemma \ref{cohomology-lemma-internal-hom-evaluate}
for the second arrow)
is an isomorphism for all $L$ because this is true on affines by
Dualizing Complexes, Lemma \ref{dualizing-lemma-dualizing}\footnote{An
alternative is to first show that
$R\SheafHom_{\mathcal{O}_X}(K, K) = \mathcal{O}_X$ by
working affine locally and then use
Lemma \ref{lemma-internal-hom-evaluate-isom} part (2)
to see the map is an isomorphism.}
and we have already seen on affines that we recover what
happens in algebra.
The statement on boundedness properties of the functor $D$
in the quasi-compact case also follows from the corresponding
statements of Dualizing Complexes, Lemma \ref{dualizing-lemma-dualizing}.
\end{proof}

\noindent
Let $X$ be a locally ringed space. Recall that an object $L$ of
$D(\mathcal{O}_X)$ is {\it invertible} if it is an invertible object
for the symmetric monoidal structure on $D(\mathcal{O}_X)$ given
by derived tensor product. In
Cohomology, Lemma \ref{cohomology-lemma-invertible-derived}
we have seen this means $L$ is perfect and there is an open covering
$X = \bigcup U_i$ such that $L|_{U_i} \cong \mathcal{O}_{U_i}[-n_i]$
for some integers $n_i$. In this case, the function
$$
x \mapsto n_x,\quad
\text{where }n_x\text{ is the unique integer such that }
H^{n_x}(L_x) \not = 0
$$
is locally constant on $X$. In particular, we have
$L = \bigoplus H^n(L)[-n]$ which gives a well defined complex of
$\mathcal{O}_X$-modules (with zero differentials) representing $L$.

\begin{lemma}
\label{lemma-dualizing-unique-schemes}
Let $X$ be a locally Noetherian scheme. If $K$ and $K'$ are dualizing
complexes on $X$, then $K'$ is isomorphic to
$K \otimes_{\mathcal{O}_X}^\mathbf{L} L$
for some invertible object $L$ of $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Set
$$
L = R\SheafHom_{\mathcal{O}_X}(K, K')
$$
This is an invertible object of $D(\mathcal{O}_X)$, because affine locally
this is true, see Dualizing Complexes, Lemma
\ref{dualizing-lemma-dualizing-unique} and its proof.
The evaluation map $L \otimes_{\mathcal{O}_X}^\mathbf{L} K \to K'$
is an isomorphism for the same reason.
\end{proof}

\begin{lemma}
\label{lemma-dimension-function-scheme}
Let $X$ be a locally Noetherian scheme. Let $\omega_X^\bullet$
be a dualizing complex on $X$. Then $X$ is universally catenary
and the function
$X \to \mathbf{Z}$ defined by
$$
x \longmapsto \delta(x)\text{ such that }
\omega_{X, x}^\bullet[-\delta(x)]
\text{ is a normalized dualizing complex over }
\mathcal{O}_{X, x}
$$
is a dimension function.
\end{lemma}

\begin{proof}
Immediate from the affine case
Dualizing Complexes, Lemma \ref{dualizing-lemma-dimension-function}
and the definitions.
\end{proof}

\begin{lemma}
\label{lemma-sitting-in-degrees}
Let $X$ be a locally Noetherian scheme. Let $\omega_X^\bullet$
be a dualizing complex on $X$ with associated dimension function $\delta$.
Let $\mathcal{F}$ be a coherent $\mathcal{O}_X$-module. Set
$\mathcal{E}^i = \SheafExt^{-i}_{\mathcal{O}_X}(\mathcal{F}, \omega_X^\bullet)$.
Then $\mathcal{E}^i$ is a coherent $\mathcal{O}_X$-module and
for $x \in X$ we have
\begin{enumerate}
\item $\mathcal{E}^i_x$ is nonzero only for
$\delta(x) \leq i \leq \delta(x) + \dim(\text{Supp}(\mathcal{F}_x))$,
\item $\dim(\text{Supp}(\mathcal{E}^{i + \delta(x)}_x)) \leq i$,
\item $\text{depth}(\mathcal{F}_x)$ is the smallest integer
$i \geq 0$ such that $\mathcal{E}_x^{i + \delta(x)} \not = 0$, and
\item we have
$x \in \text{Supp}(\bigoplus_{j \leq i} \mathcal{E}^j)
\Leftrightarrow
\text{depth}_{\mathcal{O}_{X, x}}(\mathcal{F}_x) + \delta(x) \leq i$.
\end{enumerate}
\end{lemma}

\begin{proof}
Lemma \ref{lemma-dualizing-schemes} tells us that $\mathcal{E}^i$
is coherent. Choosing an affine neighbourhood of $x$ and using
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-internal-hom}
and
More on Algebra, Lemma
\ref{more-algebra-lemma-base-change-RHom} part (3)
we have
$$
\mathcal{E}^i_x =
\SheafExt^{-i}_{\mathcal{O}_X}(\mathcal{F}, \omega_X^\bullet)_x =
\Ext^{-i}_{\mathcal{O}_{X, x}}(\mathcal{F}_x,
\omega_{X, x}^\bullet) =
\Ext^{\delta(x) - i}_{\mathcal{O}_{X, x}}(\mathcal{F}_x,
\omega_{X, x}^\bullet[-\delta(x)])
$$
By construction of $\delta$ in Lemma \ref{lemma-dimension-function-scheme}
this reduces parts (1), (2), and (3) to
Dualizing Complexes, Lemma \ref{dualizing-lemma-sitting-in-degrees}.
Part (4) is a formal consequence of (3) and (1).
\end{proof}




\section{Right adjoint of pushforward}
\label{section-twisted-inverse-image}

\noindent
References for this section and the following are
\cite{Neeman-Grothendieck}, \cite{LN},
\cite{Lipman-notes}, and \cite{Neeman-improvement}.

\medskip\noindent
Let $f : X \to Y$ be a morphism of schemes.
In this section we consider the right adjoint to the functor
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$.
In the literature, if this functor exists, then it is sometimes
denoted $f^{\times}$. This notation is not universally accepted and we refrain
from using it. We will not use the notation $f^!$ for such a functor,
as this would clash (for general morphisms $f$) with the notation in
\cite{RD}.

\begin{lemma}
\label{lemma-twisted-inverse-image}
\begin{reference}
This is almost the same as \cite[Example 4.2]{Neeman-Grothendieck}.
\end{reference}
Let $f : X \to Y$ be a morphism between quasi-separated and quasi-compact
schemes. The functor $Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$
has a right adjoint.
\end{lemma}

\begin{proof}
We will prove a right adjoint exists by verifying the hypotheses of
Derived Categories, Proposition \ref{derived-proposition-brown}.
First off, the category $D_\QCoh(\mathcal{O}_X)$ has direct sums, see
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-direct-sums}.
The category $D_\QCoh(\mathcal{O}_X)$ is compactly generated by
Derived Categories of Schemes, Theorem
\ref{perfect-theorem-bondal-van-den-Bergh}.
Since $X$ and $Y$ are quasi-compact and quasi-separated, so is $f$, see
Schemes, Lemmas \ref{schemes-lemma-compose-after-separated} and
\ref{schemes-lemma-quasi-compact-permanence}.
Hence the functor $Rf_*$ commutes with direct sums, see
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-pushforward-direct-sums}.
This finishes the proof.
\end{proof}

\begin{example}
\label{example-affine-twisted-inverse-image}
Let $A \to B$ be a ring map. Let $Y = \Spec(A)$ and $X = \Spec(B)$
and $f : X \to Y$ the morphism corresponding to $A \to B$.
Then $Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$
corresponds to restriction $D(B) \to D(A)$ via
the equivalences $D(B) \to D_\QCoh(\mathcal{O}_X)$ and
$D(A) \to D_\QCoh(\mathcal{O}_Y)$. Hence the right adjoint
corresponds to the functor $K \longmapsto R\Hom(B, K)$ of
Dualizing Complexes, Section \ref{dualizing-section-trivial}.
\end{example}

\begin{example}
\label{example-does-not-preserve-coherent}
If $f : X \to Y$ is a separated finite type morphism of Noetherian schemes,
then the right adjoint of
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$ does not map
$D_{\textit{Coh}}(\mathcal{O}_Y)$ into
$D_{\textit{Coh}}(\mathcal{O}_X)$. Namely, let $k$ be a field and
consider the morphism $f : \mathbf{A}^1_k \to \Spec(k)$. By
Example \ref{example-affine-twisted-inverse-image}
this corresponds to the question of whether
$R\Hom(B, -)$ maps $D_{\textit{Coh}}(A)$ into $D_{\textit{Coh}}(B)$
where $A = k$ and $B = k[x]$. This is not true because
$$
R\Hom(k[x], k) = \left(\prod\nolimits_{n \geq 0} k\right)[0]
$$
which is not a finite $k[x]$-module. Hence $a(\mathcal{O}_Y)$
does not have coherent cohomology sheaves.
\end{example}

\begin{example}
\label{example-does-not-preserve-bounded-above}
If $f : X \to Y$ is a proper or even finite morphism of Noetherian schemes,
then the right adjoint of
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$
does not map $D_\QCoh^-(\mathcal{O}_Y)$ into
$D_\QCoh^-(\mathcal{O}_X)$. Namely, let $k$ be a field, let
$k[\epsilon]$ be the dual numbers over $k$, let
$X = \Spec(k)$, and let $Y = \Spec(k[\epsilon])$.
Then $\Ext^i_{k[\epsilon]}(k, k)$ is nonzero for all $i \geq 0$.
Hence $a(\mathcal{O}_Y)$ is not bounded above
by Example \ref{example-affine-twisted-inverse-image}.
\end{example}

\begin{lemma}
\label{lemma-twisted-inverse-image-bounded-below}
Let $f : X \to Y$ be a morphism of quasi-compact and quasi-separated
schemes. Let $a : D_\QCoh(\mathcal{O}_Y) \to D_\QCoh(\mathcal{O}_X)$
be the right adjoint to $Rf_*$ of Lemma \ref{lemma-twisted-inverse-image}.
Then $a$ maps $D^+_\QCoh(\mathcal{O}_Y)$ into $D^+_\QCoh(\mathcal{O}_X)$.
In fact, there exists an integer $N$ such that
$H^i(K) = 0$ for $i \leq c$ implies $H^i(a(K)) = 0$ for $i \leq c - N$.
\end{lemma}

\begin{proof}
By Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-direct-image}
the functor $Rf_*$ has finite cohomological dimension. In other words,
there exist an integer $N$ such that
$H^i(Rf_*L) = 0$ for $i \geq N + c$ if $H^i(L) = 0$ for $i \geq c$.
Say $K \in D^+_\QCoh(\mathcal{O}_Y)$ has $H^i(K) = 0$ for $i \leq c$.
Then
$$
\Hom_{D(\mathcal{O}_X)}(\tau_{\leq c - N}a(K), a(K)) =
\Hom_{D(\mathcal{O}_Y)}(Rf_*\tau_{\leq c - N}a(K), K) = 0
$$
by what we said above. Clearly, this implies that
$H^i(a(K)) = 0$ for $i \leq c - N$.
\end{proof}

\noindent
Let $f : X \to Y$ be a morphism of quasi-separated and quasi-compact
schemes. Let $a$ denote the right adjoint to
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$. For every
$K \in D_\QCoh(\mathcal{O}_Y)$ and $L \in D_\QCoh(\mathcal{O}_X)$
we obtain a canonical map
\begin{equation}
\label{equation-sheafy-trace}
Rf_*R\SheafHom_{\mathcal{O}_X}(L, a(K))
\longrightarrow
R\SheafHom_{\mathcal{O}_Y}(Rf_*L, K)
\end{equation}
Namely, this map is constructed as the composition
$$
Rf_*R\SheafHom_{\mathcal{O}_X}(L, a(K)) \to
R\SheafHom_{\mathcal{O}_Y}(Rf_*L, Rf_*a(K)) \to
R\SheafHom_{\mathcal{O}_Y}(Rf_*L, K)
$$
where the first arrow is 
Cohomology, Remark
\ref{cohomology-remark-projection-formula-for-internal-hom}
and the second arrow is the counit $Rf_*a(K) \to K$ of the adjunction.

\begin{lemma}
\label{lemma-iso-on-RSheafHom}
Let $f : X \to Y$ be a morphism of quasi-compact and quasi-separated schemes.
Let $a$ be the right adjoint to
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$.
Let $L \in D_\QCoh(\mathcal{O}_X)$ and $K \in D_\QCoh(\mathcal{O}_Y)$.
Then the map (\ref{equation-sheafy-trace})
$$
Rf_*R\SheafHom_{\mathcal{O}_X}(L, a(K))
\longrightarrow
R\SheafHom_{\mathcal{O}_Y}(Rf_*L, K)
$$
becomes an isomorphism after applying the functor
$DQ_Y : D(\mathcal{O}_Y) \to D_\QCoh(\mathcal{O}_Y)$
discussed in Derived Categories of Schemes, Section
\ref{perfect-section-better-coherator}.
\end{lemma}

\begin{proof}
The statement makes sense as $DQ_Y$ exists by
Derived Categories of Schemes, Lemma \ref{perfect-lemma-better-coherator}.
Since $DQ_Y$ is the right adjoint to the inclusion
functor $D_\QCoh(\mathcal{O}_Y) \to D(\mathcal{O}_Y)$
to prove the lemma we have to show that for any $M \in D_\QCoh(\mathcal{O}_Y)$
the map (\ref{equation-sheafy-trace}) induces an bijection
$$
\Hom_Y(M, Rf_*R\SheafHom_{\mathcal{O}_X}(L, a(K)))
\longrightarrow
\Hom_Y(M, R\SheafHom_{\mathcal{O}_Y}(Rf_*L, K))
$$
To see this we use the following string of equalities
\begin{align*}
\Hom_Y(M, Rf_*R\SheafHom_{\mathcal{O}_X}(L, a(K)))
& =
\Hom_X(Lf^*M, R\SheafHom_{\mathcal{O}_X}(L, a(K))) \\
& =
\Hom_X(Lf^*M \otimes_{\mathcal{O}_X}^\mathbf{L} L, a(K)) \\
& =
\Hom_Y(Rf_*(Lf^*M \otimes_{\mathcal{O}_X}^\mathbf{L} L), K) \\
& =
\Hom_Y(M \otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*L, K) \\
& =
\Hom_Y(M, R\SheafHom_{\mathcal{O}_Y}(Rf_*L, K))
\end{align*}
The first equality holds by Cohomology, Lemma \ref{cohomology-lemma-adjoint}.
The second equality by Cohomology, Lemma \ref{cohomology-lemma-internal-hom}.
The third equality by construction of $a$.
The fourth equality by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-cohomology-base-change} (this is the important step).
The fifth by Cohomology, Lemma \ref{cohomology-lemma-internal-hom}.
\end{proof}

\begin{example}
\label{example-iso-on-RSheafHom}
The statement of Lemma \ref{lemma-iso-on-RSheafHom} is not true without
applying the ``coherator'' $DQ_Y$. Indeed, suppose $Y = \Spec(R)$ and
$X = \mathbf{A}^1_R$. Take $L = \mathcal{O}_X$ and $K = \mathcal{O}_Y$.
The left hand side of the arrow is in $D_\QCoh(\mathcal{O}_Y)$ but
the right hand side of the arrow is isomorphic to
$\prod_{n \geq 0} \mathcal{O}_Y$ which is not quasi-coherent.
\end{example}

\begin{remark}
\label{remark-iso-on-RSheafHom}
In the situation of Lemma \ref{lemma-iso-on-RSheafHom} we have
$$
DQ_Y(Rf_*R\SheafHom_{\mathcal{O}_X}(L, a(K))) =
Rf_* DQ_X(R\SheafHom_{\mathcal{O}_X}(L, a(K)))
$$
by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-pushforward-better-coherator}.
Thus if $R\SheafHom_{\mathcal{O}_X}(L, a(K)) \in D_\QCoh(\mathcal{O}_X)$,
then we can ``erase'' the $DQ_Y$ on the left hand side of the arrow.
On the other hand, if we know that
$R\SheafHom_{\mathcal{O}_Y}(Rf_*L, K) \in D_\QCoh(\mathcal{O}_Y)$,
then we can ``erase'' the $DQ_Y$ from the right hand side of the arrow.
If both are true then we see that (\ref{equation-sheafy-trace})
is an isomorphism. Combining this with
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-internal-hom}
we see that $Rf_*R\SheafHom_{\mathcal{O}_X}(L, a(K)) \to
R\SheafHom_{\mathcal{O}_Y}(Rf_*L, K)$ is an isomorphism if
\begin{enumerate}
\item $L$ and $Rf_*L$ are perfect, or
\item $K$ is bounded below and $L$ and $Rf_*L$ are pseudo-coherent.
\end{enumerate}
For (2) we use that $a(K)$ is bounded below if $K$
is bounded below, see Lemma \ref{lemma-twisted-inverse-image-bounded-below}.
\end{remark}

\begin{example}
\label{example-iso-on-RSheafHom-noetherian}
Let $f : X \to Y$ be a proper morphism of Noetherian schemes,
$L \in D^-_{\textit{Coh}}(X)$ and $K \in D^+_{\QCoh}(\mathcal{O}_Y)$.
Then the map $Rf_*R\SheafHom_{\mathcal{O}_X}(L, a(K)) \to
R\SheafHom_{\mathcal{O}_Y}(Rf_*L, K)$ is an isomorphism.
Namely, the complexes $L$ and $Rf_*L$ are pseudo-coherent by
Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-identify-pseudo-coherent-noetherian} and
\ref{perfect-lemma-direct-image-coherent}
and the discussion in Remark \ref{remark-iso-on-RSheafHom} applies.
\end{example}

\begin{lemma}
\label{lemma-iso-global-hom}
Let $f : X \to Y$ be a morphism of quasi-separated and quasi-compact
schemes.
For all $L \in D_\QCoh(\mathcal{O}_X)$ and $K \in D_\QCoh(\mathcal{O}_Y)$
(\ref{equation-sheafy-trace}) induces an isomorphism
$R\Hom_X(L, a(K)) \to R\Hom_Y(Rf_*L, K)$ of global derived homs.
\end{lemma}

\begin{proof}
By the construction in
Cohomology, Section \ref{cohomology-section-global-RHom}
we have
$$
R\Hom_X(L, a(K)) =
R\Gamma(X, R\SheafHom_{\mathcal{O}_X}(L, a(K))) =
R\Gamma(Y, Rf_*R\SheafHom_{\mathcal{O}_X}(L, a(K)))
$$
and
$$
R\Hom_Y(Rf_*L, K) = R\Gamma(Y, R\SheafHom_{\mathcal{O}_Y}(Rf_*L, K))
$$
Thus the lemma is a consequence of Lemma \ref{lemma-iso-on-RSheafHom}.
Namely, a map $E \to E'$ in $D(\mathcal{O}_Y)$ which induces
an isomorphism $DQ_Y(E) \to DQ_Y(E')$ induces a quasi-isomorphism
$R\Gamma(Y, E) \to R\Gamma(Y, E')$. Indeed we have
$H^i(Y, E) = \Ext^i_Y(\mathcal{O}_Y, E) = \Hom(\mathcal{O}_Y[-i], E) =
\Hom(\mathcal{O}_Y[-i], DQ_Y(E))$ because $\mathcal{O}_Y[-i]$
is in $D_\QCoh(\mathcal{O}_Y)$ and $DQ_Y$ is the right adjoint
to the inclusion functor $D_\QCoh(\mathcal{O}_Y) \to D(\mathcal{O}_Y)$.
\end{proof}







\section{Right adjoint of pushforward and restriction to opens}
\label{section-restriction-to-opens}

\noindent
In this section we study the question to what extent the right adjoint
of pushforward commutes with restriction to open subschemes. This is
a base change question, so let's first discuss this more generally.

\medskip\noindent
We often want to know whether the right adjoints to pushforward commutes
with base change. Thus we consider a cartesian square
\begin{equation}
\label{equation-base-change}
\vcenter{
\xymatrix{
X' \ar[r]_{g'} \ar[d]_{f'} & X \ar[d]^f \\
Y' \ar[r]^g & Y
}
}
\end{equation}
of quasi-compact and quasi-separated schemes.
Denote
$$
a  : D_\QCoh(\mathcal{O}_Y) \to D_\QCoh(\mathcal{O}_X)
\quad\text{and}\quad
a'  : D_\QCoh(\mathcal{O}_{Y'}) \to D_\QCoh(\mathcal{O}_{X'})
$$
the right adjoints to $Rf_*$ and $Rf'_*$
(Lemma \ref{lemma-twisted-inverse-image}).
Consider the base change map of
Cohomology, Remark \ref{cohomology-remark-base-change}.
It induces a transformation of functors
$$
Lg^* \circ Rf_* \longrightarrow Rf'_* \circ L(g')^*
$$
on derived categories of sheaves with quasi-coherent cohomology.
Hence a transformation between the right adjoints in the opposite direction
$$
a \circ Rg_* \longleftarrow Rg'_* \circ a'
$$

\begin{lemma}
\label{lemma-flat-precompose-pus}
In diagram (\ref{equation-base-change}) assume that $g$ is flat or
more generally that $f$ and $g$ are Tor independent. Then
$a \circ Rg_* \leftarrow Rg'_* \circ a'$ is an isomorphism.
\end{lemma}

\begin{proof}
In this case the base change map
$Lg^* \circ Rf_* K \longrightarrow Rf'_* \circ L(g')^*K$
is an isomorphism for every $K$ in $D_\QCoh(\mathcal{O}_X)$ by
Derived Categories of Schemes, Lemma \ref{perfect-lemma-compare-base-change}.
Thus the corresponding transformation between adjoint functors
is an isomorphism as well.
\end{proof}

\noindent
Let $f : X \to Y$ be a morphism of quasi-compact and quasi-separated
schemes. Let $V \subset Y$ be a quasi-compact open subscheme and set
$U = f^{-1}(V)$. This gives a cartesian square
$$
\xymatrix{
U \ar[r]_{j'} \ar[d]_{f|_U} & X \ar[d]^f \\
V \ar[r]^j & Y
}
$$
as in (\ref{equation-base-change}). By Lemma \ref{lemma-flat-precompose-pus}
the map $\xi : a \circ Rj_* \leftarrow Rj'_* \circ a'$ is an isomorphism
where $a$ and $a'$ are the right adjoints to
$Rf_*$ and $R(f|_U)_*$. We obtain a transformation
of functors $D_\QCoh(\mathcal{O}_Y) \to D_\QCoh(\mathcal{O}_U)$
\begin{equation}
\label{equation-sheafy}
(j')^* \circ a \to
(j')^* \circ a \circ Rj_* \circ j^* \xrightarrow{\xi^{-1}}
(j')^* \circ Rj'_* \circ a' \circ j^* \to a' \circ j^*
\end{equation}
where the first arrow comes from $\text{id} \to Rj_* \circ j^*$
and the final arrow from the isomorphism $(j')^* \circ Rj'_* \to \text{id}$.
In particular, we see that (\ref{equation-sheafy}) is an isomorphism
when evaluated on $K$ if and only if $a(K)|_U \to a(Rj_*(K|_V))|_U$
is an isomorphism.

\begin{example}
\label{example-not-supported-on-inverse-image}
There is a finite morphism $f : X \to Y$ of Noetherian schemes
such that (\ref{equation-sheafy}) is not an isomorphism
when evaluated on some
$K \in D_{\textit{Coh}}(\mathcal{O}_Y)$.
Namely, let $X = \Spec(B) \to Y = \Spec(A)$ with
$A = k[x, \epsilon]$ where $k$ is a field and $\epsilon^2 = 0$ and
$B = k[x] = A/(\epsilon)$. For $n \in \mathbf{N}$ set
$M_n = A/(\epsilon, x^n)$. Observe that
$$
\Ext^i_A(B, M_n) = M_n,\quad i \geq 0
$$
because $B$ has the free periodic resolution
$\ldots \to A \to A \to A$ with maps given by multiplication by $\epsilon$.
Consider the object
$K = \bigoplus M_n[n] = \prod M_n[n]$
of $D_{\textit{Coh}}(A)$ (equality in $D(A)$ by
Derived Categories, Lemmas \ref{derived-lemma-direct-sums} and
\ref{derived-lemma-products}). Then we see that $a(K)$ corresponds
to $R\Hom(B, K)$ by Example \ref{example-affine-twisted-inverse-image} and
$$
H^0(R\Hom(B, K)) = \Ext^0_A(B, K) =
\prod\nolimits_{n \geq 1} \Ext^n_A(B. M_n) = 
\prod\nolimits_{n \geq 1} M_n
$$
by the above. But this module has elements which are not
annihilated by any power of $x$, whereas the complex $K$
does have every element of its cohomology annihilated by
a power of $x$. In other words, for the map (\ref{equation-sheafy})
with $V = D(x)$ and $U = D(x)$ and the complex $K$ cannot
be an isomorphism because $(j')^*(a(K))$ is nonzero and
$a'(j^*K)$ is zero.
\end{example}

\begin{lemma}
\label{lemma-when-sheafy}
Let $f : X \to Y$ be a morphism of quasi-compact and quasi-separated
schemes. Let $a$ be the right adjoint to
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$.
Let $V \subset Y$ be quasi-compact open with inverse image $U \subset X$.
\begin{enumerate}
\item For every $Q \in D_\QCoh^+(\mathcal{O}_Y)$
supported on $Y \setminus V$ the image $a(Q)$ is supported on
$X \setminus U$ if and only if (\ref{equation-sheafy})
is an isomorphism on all $K$ in $D_\QCoh^+(\mathcal{O}_Y)$.
\item For every $Q \in D_\QCoh(\mathcal{O}_Y)$
supported on $Y \setminus V$ the image $a(Q)$ is supported on
$X \setminus U$ if and only if (\ref{equation-sheafy})
is an isomorphism on all $K$ in $D_\QCoh(\mathcal{O}_Y)$.
\item If $a$ commutes with direct sums, then the equivalent conditions of
(1) imply the equivalent conditions of (2).
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). Let $K \in D_\QCoh^+(\mathcal{O}_Y)$.
Choose a distinguished triangle
$$
K \to Rj_*K|_V \to Q \to K[1]
$$
Observe that $Q$ is in $D_\QCoh^+(\mathcal{O}_Y)$
(Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-direct-image})
and is supported on $Y \setminus V$
(Derived Categories of Schemes, Definition
\ref{perfect-definition-supported-on}).
Applying $a$ we obtain a distinguished triangle
$$
a(K) \to a(Rj_*K|_V) \to a(Q) \to a(K)[1]
$$
on $X$. If $a(Q)$ is supported on $X \setminus U$, then
restricting to $U$ the map $a(K)|_U \to a(Rj_*K|_V)|_U$ is an
isomorphism, i.e., (\ref{equation-sheafy}) is an isomorphism on $K$.
The converse is immediate.

\medskip\noindent
The proof of (2) is exactly the same as the proof of (1).

\medskip\noindent
Proof of (3). Assume the equivalent conditions of (1) hold.
Set $T = Y \setminus V$.
We will use the notation $D_{\QCoh, T}(\mathcal{O}_Y)$ and
$D_{\QCoh, f^{-1}(T)}(\mathcal{O}_X)$ to denote complexes
whose cohomology sheaves are supported on $T$ and $f^{-1}(T)$.
Since $a$ commutes with direct sums, the strictly full, saturated, triangulated
subcategory $\mathcal{D}$ with objects
$$
\{Q \in D_{\QCoh, T}(\mathcal{O}_Y) \mid
a(Q) \in D_{\QCoh, f^{-1}(T)}(\mathcal{O}_X)\}
$$
is preserved by direct sums and hence derived colimits.
On the other hand, the category $D_{\QCoh, T}(\mathcal{O}_Y)$
is generated by a perfect object $E$
(see Derived Categories of Schemes, Lemma
\ref{perfect-lemma-generator-with-support}).
By assumption we see that $E \in \mathcal{D}$.
By Derived Categories, Lemma \ref{derived-lemma-write-as-colimit}
every object $Q$ of $D_{\QCoh, T}(\mathcal{O}_Y)$ is a derived
colimit of a system $Q_1 \to Q_2 \to Q_3 \to \ldots$
such that the cones of the transition maps are direct sums
of shifts of $E$. Arguing by induction we see that
$Q_n \in \mathcal{D}$ for all $n$ and finally that $Q$ is
in $\mathcal{D}$. Thus the equivalent conditions of (2) hold.
\end{proof}

\begin{lemma}
\label{lemma-proper-noetherian}
Let $Y$ be a quasi-compact and quasi-separated scheme.
Let $f : X \to Y$ be a proper morphism. If\footnote{This proof works for those
morphisms of quasi-compact and quasi-separated schemes such that
$Rf_*P$ is pseudo-coherent for all $P$ perfect on $X$. It follows
easily from a theorem of Kiehl \cite{Kiehl} that this holds if
$f$ is proper and pseudo-coherent. This is the correct generality
for this lemma and some of the other results in this chapter.}
\begin{enumerate}
\item $f$ is flat and of finite presentation, or
\item $Y$ is Noetherian
\end{enumerate}
then the equivalent conditions of Lemma \ref{lemma-when-sheafy} part (1)
hold for all quasi-compact opens $V$ of $Y$.
\end{lemma}

\begin{proof}
Let $Q \in D^+_\QCoh(\mathcal{O}_Y)$ be supported on $Y \setminus V$.
To get a contradiction, assume that $a(Q)$ is not supported on
$X \setminus U$. Then we can find a perfect complex $P_U$ on $U$
and a nonzero map $P_U \to a(Q)|_U$ (follows from
Derived Categories of Schemes, Theorem
\ref{perfect-theorem-bondal-van-den-Bergh}). Then using
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-lift-map-from-perfect-complex-with-support}
we may assume there is a perfect complex $P$ on $X$ and a map
$P \to a(Q)$ whose restriction to $U$ is nonzero.
By definition of $a$ this map
is adjoint to a map $Rf_*P \to Q$.

\medskip\noindent
The complex $Rf_*P$ is pseudo-coherent. In case (1) this follows
from Derived Categories of Schemes, Lemma
\ref{perfect-lemma-flat-proper-pseudo-coherent-direct-image-general}.
In case (2) this follows from
Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-direct-image-coherent} and
\ref{perfect-lemma-identify-pseudo-coherent-noetherian}.
Thus we may apply
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-map-from-pseudo-coherent-to-complex-with-support}
and get a map $I \to \mathcal{O}_Y$ of perfect complexes
whose restriction to $V$ is an isomorphism such that the composition
$I \otimes^\mathbf{L}_{\mathcal{O}_Y} Rf_*P \to Rf_*P \to Q$ is zero.
By Derived Categories of Schemes, Lemma
\ref{perfect-lemma-cohomology-base-change}
we have $I \otimes^\mathbf{L}_{\mathcal{O}_Y} Rf_*P =
Rf_*(Lf^*I \otimes^\mathbf{L}_{\mathcal{O}_X} P)$.
We conclude that the composition
$$
Lf^*I \otimes^\mathbf{L}_{\mathcal{O}_X} P \to P \to a(Q)
$$
is zero. However, the restriction to $U$ is the map
$P|_U \to a(Q)|_U$ which we assumed to be nonzero.
This contradiction finishes the proof.
\end{proof}












\section{Right adjoint of pushforward and base change, I}
\label{section-base-change-map}

\noindent
The map (\ref{equation-sheafy}) is a special case of a base change map.
Namely, suppose that we have a cartesian diagram
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d]_{f'} & X \ar[d]^f \\
Y' \ar[r]^g & Y
}
$$
of quasi-compact and quasi-separated schemes, i.e., a diagram as in
(\ref{equation-base-change}). Assume $f$ and $g$ are {\bf Tor independent}.
Then we can consider the morphism of functors
$D_\QCoh(\mathcal{O}_Y) \to D_\QCoh(\mathcal{O}_{X'})$
given by the composition
\begin{equation}
\label{equation-base-change-map}
L(g')^* \circ a \to
L(g')^* \circ a \circ Rg_* \circ Lg^* \leftarrow
L(g')^* \circ Rg'_* \circ a' \circ Lg^* \to a' \circ Lg^*
\end{equation}
The first arrow comes from the adjunction map $\text{id} \to Rg_* Lg^*$
and the last arrow from the adjunction map $L(g')^*Rg'_* \to \text{id}$.
We need the assumption on Tor independence to invert the arrow
in the middle, see Lemma \ref{lemma-flat-precompose-pus}.
Alternatively, we can think of (\ref{equation-base-change-map}) by
adjointness of $L(g')^*$ and $R(g')_*$ as a natural transformation
$$
a \to a \circ Rg_* \circ Lg^* \leftarrow Rg'_* \circ a' \circ Lg^*
$$
were again the second arrow is invertible. If $M \in D_\QCoh(\mathcal{O}_X)$
and $K \in D_\QCoh(\mathcal{O}_Y)$
then on Yoneda functors this map is given by
\begin{align*}
\Hom_X(M, a(K))
& =
\Hom_Y(Rf_*M, K) \\
& \to
\Hom_Y(Rf_*M, Rg_* Lg^*K) \\
& =
\Hom_{Y'}(Lg^*Rf_*M, Lg^*K) \\
& \leftarrow
\Hom_{Y'}(Rf'_* L(g')^*M, Lg^*K) \\
& =
\Hom_{X'}(L(g')^*M, a'(Lg^*K)) \\
& =
\Hom_X(M, Rg'_*a'(Lg^*K))
\end{align*}
(were the arrow pointing left is invertible by the base
change theorem given in
Derived Categories of Schemes, Lemma \ref{perfect-lemma-compare-base-change})
which makes things a little bit more explicit.

\medskip\noindent
In this section we first prove that the base change map satisfies
some natural compatibilities with regards to stacking squares as in
Cohomology, Remarks \ref{cohomology-remark-compose-base-change} and
\ref{cohomology-remark-compose-base-change-horizontal} for the usual
base change map. We suggest the reader skip the rest of this section
on a first reading.

\begin{lemma}
\label{lemma-compose-base-change-maps}
Consider a commutative diagram
$$
\xymatrix{
X' \ar[r]_k \ar[d]_{f'} & X \ar[d]^f \\
Y' \ar[r]^l \ar[d]_{g'} & Y \ar[d]^g \\
Z' \ar[r]^m & Z
}
$$
of quasi-compact and quasi-separated schemes where
both diagrams are cartesian and where $f$ and $l$
as well as $g$ and $m$ are Tor independent.
Then the maps (\ref{equation-base-change-map})
for the two squares compose to give the base
change map for the outer rectangle (see proof for a precise statement).
\end{lemma}

\begin{proof}
It follows from the assumptions that $g \circ f$ and $m$ are Tor
independent (details omitted), hence the statement makes sense.
In this proof we write $k^*$ in place of $Lk^*$ and $f_*$ instead
of $Rf_*$. Let $a$, $b$, and $c$ be the right adjoints of
Lemma \ref{lemma-twisted-inverse-image}
for $f$, $g$, and $g \circ f$ and similarly for the primed versions.
The arrow corresponding to the top square is the composition
$$
\gamma_{top} :
k^* \circ a \to k^* \circ a \circ l_* \circ l^*
\xleftarrow{\xi_{top}} k^* \circ k_* \circ a' \circ l^* \to a' \circ l^*
$$
where $\xi_{top} : k_* \circ a' \to a \circ l_*$
is an isomorphism (hence can be inverted)
and is the arrow ``dual'' to the base change map
$l^* \circ f_* \to f'_* \circ k^*$. The outer arrows come
from the canonical maps $1 \to l_* \circ l^*$ and $k^* \circ k_* \to 1$.
Similarly for the second square we have
$$
\gamma_{bot} :
l^* \circ b \to l^* \circ b \circ m_* \circ m^*
\xleftarrow{\xi_{bot}} l^* \circ l_* \circ b' \circ m^* \to b' \circ m^*
$$
For the outer rectangle we get
$$
\gamma_{rect} :
k^* \circ c \to k^* \circ c \circ m_* \circ m^*
\xleftarrow{\xi_{rect}} k^* \circ k_* \circ c' \circ m^* \to c' \circ m^*
$$
We have $(g \circ f)_* = g_* \circ f_*$ and hence
$c = a \circ b$ and similarly $c' = a' \circ b'$.
The statement of the lemma is that $\gamma_{rect}$
is equal to the composition
$$
k^* \circ c = k^* \circ a \circ b \xrightarrow{\gamma_{top}}
a' \circ l^* \circ b \xrightarrow{\gamma_{bot}}
a' \circ b' \circ m^* = c' \circ m^*
$$
To see this we contemplate the following diagram:
$$
\xymatrix{
& & k^* \circ a \circ b \ar[d] \ar[lldd] \\
& & k^* \circ a \circ l_* \circ l^* \circ b \ar[ld] \\
k^* \circ a \circ b \circ m_* \circ m^* \ar[r] &
k^* \circ a \circ l_* \circ l^* \circ b \circ m_* \circ m^* &
k^* \circ k_* \circ a' \circ l^* \circ b \ar[u]_{\xi_{top}} \ar[d] \ar[ld] \\
& k^*\circ k_* \circ a' \circ l^* \circ b \circ m_* \circ m^*
\ar[u]_{\xi_{top}} \ar[rd] &
a' \circ l^* \circ b \ar[d] \\
k^* \circ k_* \circ a' \circ b' \circ m^* \ar[uu]_{\xi_{rect}} \ar[ddrr] &
k^*\circ k_* \circ a' \circ l^* \circ l_* \circ b' \circ m^*
\ar[u]_{\xi_{bot}} \ar[l] \ar[dr] &
a' \circ l^* \circ b \circ m_* \circ m^* \\
& & a' \circ l^* \circ l_* \circ b' \circ m^* \ar[u]_{\xi_{bot}} \ar[d] \\
& & a' \circ b' \circ m^*
}
$$
Going down the right hand side we have the composition and going
down the left hand side we have $\gamma_{rect}$.
All the quadrilaterals on the right hand side of this diagram commute
by Categories, Lemma \ref{categories-lemma-properties-2-cat-cats}
or more simply the discussion preceding
Categories, Definition \ref{categories-definition-horizontal-composition}.
Hence we see that it suffices to show the diagram
$$
\xymatrix{
a \circ l_* \circ l^* \circ b \circ m_* &
a \circ b \circ m_* \ar[l] \\
k_* \circ a' \circ l^* \circ b \circ m_* \ar[u]_{\xi_{top}} & \\
k_* \circ a' \circ l^* \circ l_* \circ b' \ar[u]_{\xi_{bot}} \ar[r] &
k_* \circ a' \circ b' \ar[uu]_{\xi_{rect}}
}
$$
becomes commutative if we invert the arrows $\xi_{top}$, $\xi_{bot}$,
and $\xi_{rect}$ (note that this is different from asking the
diagram to be commutative). However, the diagram
$$
\xymatrix{
& a \circ l_* \circ l^* \circ b \circ m_* \\
a \circ l_* \circ l^* \circ l_* \circ b'
\ar[ru]^{\xi_{bot}} & &
k_* \circ a' \circ l^* \circ b \circ m_* \ar[ul]_{\xi_{top}} \\
& k_* \circ a' \circ l^* \circ l_* \circ b'
\ar[ul]^{\xi_{top}} \ar[ur]_{\xi_{bot}}
}
$$
commutes by Categories, Lemma \ref{categories-lemma-properties-2-cat-cats}.
Since the diagrams
$$
\vcenter{
\xymatrix{
a \circ l_* \circ l^* \circ b \circ m_* & a \circ b \circ m \ar[l] \\
a \circ l_* \circ l^* \circ l_* \circ b' \ar[u] &
a \circ l_* \circ b' \ar[l] \ar[u]
}
}
\quad\text{and}\quad
\vcenter{
\xymatrix{
a \circ l_* \circ l^* \circ l_* \circ b' \ar[r] & a \circ l_* \circ b' \\
k_* \circ a' \circ l^* \circ l_* \circ b' \ar[u] \ar[r] &
k_* \circ a' \circ b' \ar[u]
}
}
$$
commute (see references cited) and since the composition of
$l_* \to l_* \circ l^* \circ l_* \to l_*$ is the identity,
we find that it suffices to prove that
$$
k \circ a' \circ b' \xrightarrow{\xi_{bot}} a \circ l_* \circ b
\xrightarrow{\xi_{top}} a \circ b \circ m_*
$$
is equal to $\xi_{rect}$ (via the identifications $a \circ b = c$
and $a' \circ b' = c'$). This is the statement dual to
Cohomology, Remark \ref{cohomology-remark-compose-base-change}
and the proof is complete.
\end{proof}

\begin{lemma}
\label{lemma-compose-base-change-maps-horizontal}
Consider a commutative diagram
$$
\xymatrix{
X'' \ar[r]_{g'} \ar[d]_{f''} & X' \ar[r]_g \ar[d]_{f'} & X \ar[d]^f \\
Y'' \ar[r]^{h'} & Y' \ar[r]^h & Y
}
$$
of quasi-compact and quasi-separated schemes where
both diagrams are cartesian and where $f$ and $h$
as well as $f'$ and $h'$ are Tor independent.
Then the maps (\ref{equation-base-change-map})
for the two squares compose to give the base
change map for the outer rectangle (see proof for a precise statement).
\end{lemma}

\begin{proof}
It follows from the assumptions that $f$ and $h \circ h'$ are Tor
independent (details omitted), hence the statement makes sense.
In this proof we write $g^*$ in place of $Lg^*$ and $f_*$ instead
of $Rf_*$. Let $a$, $a'$, and $a''$ be the right adjoints of
Lemma \ref{lemma-twisted-inverse-image}
for $f$, $f'$, and $f''$. The arrow corresponding to the right
square is the composition
$$
\gamma_{right} :
g^* \circ a \to g^* \circ a \circ h_* \circ h^*
\xleftarrow{\xi_{right}} g^* \circ g_* \circ a' \circ h^* \to a' \circ h^*
$$
where $\xi_{right} : g_* \circ a' \to a \circ h_*$
is an isomorphism (hence can be inverted)
and is the arrow ``dual'' to the base change map
$h^* \circ f_* \to f'_* \circ g^*$. The outer arrows come
from the canonical maps $1 \to h_* \circ h^*$ and $g^* \circ g_* \to 1$.
Similarly for the left square we have
$$
\gamma_{left} :
(g')^* \circ a' \to (g')^* \circ a' \circ (h')_* \circ (h')^*
\xleftarrow{\xi_{left}}
(g')^* \circ (g')_* \circ a'' \circ (h')^* \to a'' \circ (h')^*
$$
For the outer rectangle we get
$$
\gamma_{rect} :
k^* \circ a \to
k^* \circ a \circ m_* \circ m^* \xleftarrow{\xi_{rect}}
k^* \circ k_* \circ a'' \circ m^* \to
a'' \circ m^*
$$
where $k = g \circ g'$ and $m = h \circ h'$.
We have $k^* = (g')^* \circ g^*$ and $m^* = (h')^* \circ h^*$.
The statement of the lemma is that $\gamma_{rect}$
is equal to the composition
$$
k^* \circ a =
(g')^* \circ g^* \circ a \xrightarrow{\gamma_{right}}
(g')^* \circ a' \circ h^* \xrightarrow{\gamma_{left}}
a'' \circ (h')^* \circ h^* = a'' \circ m^*
$$
To see this we contemplate the following diagram
$$
\xymatrix{
& (g')^* \circ g^* \circ a \ar[d] \ar[ddl] \\
& (g')^* \circ g^* \circ a \circ h_* \circ h^* \ar[ld] \\
(g')^* \circ g^* \circ a \circ h_* \circ (h')_* \circ (h')^* \circ h^* &
(g')^* \circ g^* \circ g_* \circ a' \circ h^*
\ar[u]_{\xi_{right}} \ar[d] \ar[ld] \\
(g')^* \circ g^* \circ g_* \circ a' \circ (h')_* \circ (h')^* \circ h^*
\ar[u]_{\xi_{right}} \ar[dr] &
(g')^* \circ a' \circ h^* \ar[d] \\
(g')^* \circ g^* \circ g_* \circ (g')_* \circ a'' \circ (h')^* \circ h^*
\ar[u]_{\xi_{left}} \ar[ddr] \ar[dr] &
(g')^* \circ a' \circ (h')_* \circ (h')^* \circ h^* \\
& (g')^*\circ (g')_* \circ a'' \circ (h')^* \circ h^*
\ar[u]_{\xi_{left}} \ar[d] \\
& a'' \circ (h')^* \circ h^*
}
$$
Going down the right hand side we have the composition and going
down the left hand side we have $\gamma_{rect}$.
All the quadrilaterals on the right hand side of this diagram commute
by Categories, Lemma \ref{categories-lemma-properties-2-cat-cats}
or more simply the discussion preceding
Categories, Definition \ref{categories-definition-horizontal-composition}.
Hence we see that it suffices to show that
$$
g_* \circ (g')_* \circ a'' \xrightarrow{\xi_{left}}
g_* \circ a' \circ (h')_* \xrightarrow{\xi_{right}}
a \circ h_* \circ (h')_*
$$
is equal to $\xi_{rect}$. This is the statement dual to
Cohomology, Remark \ref{cohomology-remark-compose-base-change-horizontal}
and the proof is complete.
\end{proof}

\begin{remark}
\label{remark-going-around}
Consider a commutative diagram
$$
\xymatrix{
X'' \ar[r]_{k'} \ar[d]_{f''} & X' \ar[r]_k \ar[d]_{f'} & X \ar[d]^f \\
Y'' \ar[r]^{l'} \ar[d]_{g''} & Y' \ar[r]^l \ar[d]_{g'} & Y \ar[d]^g \\
Z'' \ar[r]^{m'} & Z' \ar[r]^m & Z
}
$$
of quasi-compact and quasi-separated schemes where
all squares are cartesian and where
$(f, l)$, $(g, m)$, $(f', l')$, $(g', m')$ are
Tor independent pairs of maps.
Let $a$, $a'$, $a''$, $b$, $b'$, $b''$ be the
right adjoints of Lemma \ref{lemma-twisted-inverse-image}
for $f$, $f'$, $f''$, $g$, $g'$, $g''$.
Let us label the squares of the diagram $A$, $B$, $C$, $D$
as follows
$$
\begin{matrix}
A & B \\
C & D
\end{matrix}
$$
Then the maps (\ref{equation-base-change-map})
for the squares are (where we use $k^* = Lk^*$, etc)
$$
\begin{matrix}
\gamma_A : (k')^* \circ a' \to a'' \circ (l')^* &
\gamma_B : k^* \circ a \to a' \circ l^* \\
\gamma_C : (l')^* \circ b' \to b'' \circ (m')^* &
\gamma_D : l^* \circ b \to b' \circ m^*
\end{matrix}
$$
For the $2 \times 1$ and $1 \times 2$ rectangles we have four further
base change maps
$$
\begin{matrix}
\gamma_{A + B} : (k \circ k')^* \circ a \to a'' \circ (l \circ l')^* \\
\gamma_{C + D} : (l \circ l')^* \circ b \to b'' \circ (m \circ m')^* \\
\gamma_{A + C} : (k')^* \circ (a' \circ b') \to (a'' \circ b'') \circ (m')^* \\
\gamma_{B + D} : k^* \circ (a \circ b) \to (a' \circ b') \circ m^*
\end{matrix}
$$
By Lemma \ref{lemma-compose-base-change-maps-horizontal} we have
$$
\gamma_{A + B} = \gamma_A \circ \gamma_B, \quad
\gamma_{C + D} = \gamma_C \circ \gamma_D
$$
and by Lemma \ref{lemma-compose-base-change-maps} we have
$$
\gamma_{A + C} = \gamma_C \circ \gamma_A, \quad
\gamma_{B + D} = \gamma_D \circ \gamma_B
$$
Here it would be more correct to write
$\gamma_{A + B} = (\gamma_A \star \text{id}_{l^*}) \circ
(\text{id}_{(k')^*} \star \gamma_B)$ with notation as in
Categories, Section \ref{categories-section-formal-cat-cat}
and similarly for the others. However, we continue the
abuse of notation used in the proofs of
Lemmas \ref{lemma-compose-base-change-maps} and
\ref{lemma-compose-base-change-maps-horizontal}
of dropping $\star$ products with identities as one can figure
out which ones to add as long as the source and target of the
transformation is known.
Having said all of this we find (a priori) two transformations
$$
(k')^* \circ k^* \circ a \circ b
\longrightarrow
a'' \circ b'' \circ (m')^* \circ m^*
$$
namely
$$
\gamma_C \circ \gamma_A \circ \gamma_D \circ \gamma_B =
\gamma_{A + C} \circ \gamma_{B + D}
$$
and
$$
\gamma_C \circ \gamma_D \circ \gamma_A \circ \gamma_B =
\gamma_{C + D} \circ \gamma_{A + B}
$$
The point of this remark is to point out that these transformations
are equal. Namely, to see this it suffices to show that
$$
\xymatrix{
(k')^* \circ a' \circ l^* \circ b \ar[r]_{\gamma_D} \ar[d]_{\gamma_A} &
(k')^* \circ a' \circ b' \circ m^* \ar[d]^{\gamma_A} \\
a'' \circ (l')^* \circ l^* \circ b \ar[r]^{\gamma_D} &
a'' \circ (l')^* \circ b' \circ m^*
}
$$
commutes. This is true by
Categories, Lemma \ref{categories-lemma-properties-2-cat-cats}
or more simply the discussion preceding
Categories, Definition \ref{categories-definition-horizontal-composition}.
\end{remark}







\section{Right adjoint of pushforward and base change, II}
\label{section-base-change-II}

\noindent
In this section we prove that the base change map of
Section \ref{section-base-change-map} is an isomorphism
in some cases. We first observe that it suffices to check
over affine opens, provided formation of the right adjoint
of pushforward commutes with restriction to opens.

\begin{remark}
\label{remark-check-over-affines}
Consider a cartesian diagram
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d]_{f'} & X \ar[d]^f \\
Y' \ar[r]^g & Y
}
$$
of quasi-compact and quasi-separated schemes with $(g, f)$ Tor independent.
Let $V \subset Y$ and $V' \subset Y'$ be affine opens with
$g(V') \subset V$. Form the cartesian diagrams
$$
\vcenter{
\xymatrix{
U \ar[r] \ar[d] & X \ar[d] \\
V \ar[r] & Y
}
}
\quad\text{and}\quad
\vcenter{
\xymatrix{
U' \ar[r] \ar[d] & X' \ar[d] \\
V' \ar[r] & Y'
}
}
$$
Assume (\ref{equation-sheafy}) with respect to $K$
and the first diagram and (\ref{equation-sheafy})
with respect to $Lg^*K$ and the second diagram are isomorphisms.
Then the restriction of the base change map (\ref{equation-base-change-map})
$$
L(g')^*a(K) \longrightarrow a'(Lg^*K)
$$
to $U'$ is isomorphic to the base change map
(\ref{equation-base-change-map}) for $K|_V$ and the
cartesian diagram
$$
\xymatrix{
U' \ar[r] \ar[d] & U \ar[d] \\
V' \ar[r] & V
}
$$
This follows from the fact that (\ref{equation-sheafy})
is a special case of the base change map (\ref{equation-base-change-map})
and that the base change maps compose correctly if we stack squares
horizontally, see Lemma \ref{lemma-compose-base-change-maps-horizontal}.
Thus in order to check the base change map restricted to $U'$
is an isomorphism it suffices to work with the last diagram.
\end{remark}

\begin{lemma}
\label{lemma-more-base-change}
In diagram (\ref{equation-base-change}) assume
\begin{enumerate}
\item $g : Y' \to Y$ is a morphism of affine schemes,
\item $f : X \to Y$ is proper, and
\item $f$ and $g$ are Tor independent.
\end{enumerate}
Then the base change map (\ref{equation-base-change-map}) induces an
isomorphism
$$
L(g')^*a(K) \longrightarrow a'(Lg^*K)
$$
in the following cases
\begin{enumerate}
\item for all $K \in D_\QCoh(\mathcal{O}_Y)$ if $f$
is flat of finite presentation,
\item for all $K \in D_\QCoh(\mathcal{O}_Y)$ if $f$
is perfect and $Y$ Noetherian,
\item for $K \in D_\QCoh^+(\mathcal{O}_Y)$ if $g$ has finite Tor dimension
and $Y$ Noetherian.
\end{enumerate}
\end{lemma}

\begin{proof}
Write $Y = \Spec(A)$ and $Y' = \Spec(A')$. As a base change of an affine
morphism, the morphism $g'$ is affine. Let $M$ be a perfect generator
for $D_\QCoh(\mathcal{O}_X)$, see Derived Categories of Schemes, Theorem
\ref{perfect-theorem-bondal-van-den-Bergh}. Then $L(g')^*M$ is a
generator for $D_\QCoh(\mathcal{O}_{X'})$, see
Derived Categories of Schemes, Remark \ref{perfect-remark-pullback-generator}.
Hence it suffices to show that (\ref{equation-base-change-map})
induces an isomorphism
\begin{equation}
\label{equation-iso}
R\Hom_{X'}(L(g')^*M, L(g')^*a(K))
\longrightarrow
R\Hom_{X'}(L(g')^*M, a'(Lg^*K))
\end{equation}
of global hom complexes, see
Cohomology, Section \ref{cohomology-section-global-RHom},
as this will imply the cone of $L(g')^*a(K) \to a'(Lg^*K)$
is zero.
The structure of the proof is as follows: we will first show that
these Hom complexes are isomorphic and in the last part of the proof
we will show that the isomorphism is induced by (\ref{equation-iso}).

\medskip\noindent
The left hand side. Because $M$ is perfect, the canonical map
$$
R\Hom_X(M, a(K)) \otimes^\mathbf{L}_A A'
\longrightarrow
R\Hom_{X'}(L(g')^*M, L(g')^*a(K))
$$
is an isomorphism by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-morphism-and-hom-out-of-perfect}.
We can combine this with the isomorphism
$R\Hom_Y(Rf_*M, K) = R\Hom_X(M, a(K))$
of Lemma \ref{lemma-iso-global-hom}
to get that the left hand side equals
$R\Hom_Y(Rf_*M, K) \otimes^\mathbf{L}_A A'$.

\medskip\noindent
The right hand side. Here we first use the isomorphism
$$
R\Hom_{X'}(L(g')^*M, a'(Lg^*K)) = R\Hom_{Y'}(Rf'_*L(g')^*M, Lg^*K)
$$
of Lemma \ref{lemma-iso-global-hom}. Then we use the base change
map $Lg^*Rf_*M \to Rf'_*L(g')^*M$ is an isomorphism by
Derived Categories of Schemes, Lemma \ref{perfect-lemma-compare-base-change}.
Hence we may rewrite this as $R\Hom_{Y'}(Lg^*Rf_*M, Lg^*K)$.
Since $Y$, $Y'$ are affine and $K$, $Rf_*M$ are in $D_\QCoh(\mathcal{O}_Y)$
(Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-direct-image})
we have a canonical map
$$
\beta :
R\Hom_Y(Rf_*M, K) \otimes^\mathbf{L}_A A'
\longrightarrow
R\Hom_{Y'}(Lg^*Rf_*M, Lg^*K)
$$
in $D(A')$. This is the arrow
More on Algebra, Equation (\ref{more-algebra-equation-base-change-RHom})
where we have used Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-affine-compare-bounded} and
\ref{perfect-lemma-quasi-coherence-internal-hom}
to translate back and forth into algebra.
\begin{enumerate}
\item If $f$ is flat and of finite presentation, the complex $Rf_*M$
is perfect on $Y$ by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-flat-proper-perfect-direct-image-general}
and $\beta$ is an isomorphism by
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom} part (1).
\item If $f$ is perfect and $Y$ Noetherian, the complex $Rf_*M$
is perfect on $Y$ by More on Morphisms, Lemma
\ref{more-morphisms-lemma-perfect-proper-perfect-direct-image}
and $\beta$ is an isomorphism as before.
\item If $g$ has finite tor dimension and $Y$ is Noetherian,
the complex $Rf_*M$ is pseudo-coherent on $Y$
(Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-direct-image-coherent} and
\ref{perfect-lemma-identify-pseudo-coherent-noetherian})
and $\beta$ is an isomorphism by
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom} part (4).
\end{enumerate}
We conclude that we obtain the same answer as in the previous paragraph.

\medskip\noindent
In the rest of the proof we show that the identifications of
the left and right hand side of (\ref{equation-iso})
given in the second and third paragraph are in fact given by
(\ref{equation-iso}). To make our formulas manageable
we will use $(-, -)_X = R\Hom_X(-, -)$, use $- \otimes A'$
in stead of $- \otimes_A^\mathbf{L} A'$, and we will abbreviate
$g^* = Lg^*$ and $f_* = Rf_*$. Consider the following
commutative diagram
$$
\xymatrix{
((g')^*M, (g')^*a(K))_{X'} \ar[d] &
(M, a(K))_X \otimes A' \ar[l]^-\alpha \ar[d] &
(f_*M, K)_Y \otimes A' \ar@{=}[l] \ar[d] \\
((g')^*M, (g')^*a(g_*g^*K))_{X'} &
(M, a(g_*g^*K))_X \otimes A' \ar[l]^-\alpha &
(f_*M, g_*g^*K)_Y \otimes A' \ar@{=}[l] \ar@/_4pc/[dd]_{\mu'} \\
((g')^*M, (g')^*g'_*a'(g^*K))_{X'} \ar[u] \ar[d] &
(M, g'_*a'(g^*K))_X \otimes A' \ar[u] \ar[l]^-\alpha \ar[ld]^\mu &
(f_*M, K) \otimes A' \ar[d]^\beta \\
((g')^*M, a'(g^*K))_{X'} &
(f'_*(g')^*M, g^*K)_{Y'} \ar@{=}[l] \ar[r] &
(g^*f_*M, g^*K)_{Y'}
}
$$
The arrows labeled $\alpha$ are the maps from
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-morphism-and-hom-out-of-perfect}
for the diagram with corners $X', X, Y', Y$.
The upper part of the diagram is commutative as the horizontal arrows are
functorial in the entries.
The middle vertical arrows come from the invertible transformation
$g'_* \circ a' \to a \circ g_*$  of Lemma \ref{lemma-flat-precompose-pus}
and therefore the middle square is commutative.
Going down the left hand side is (\ref{equation-iso}).
The upper horizontal arrows provide the identifications used in the
second paragraph of the proof.
The lower horizontal arrows including $\beta$ provide the identifications
used in the third paragraph of the proof. Given $E \in D(A)$,
$E' \in D(A')$, and $c : E \to E'$ in $D(A)$ we will denote
$\mu_c : E \otimes A' \to E'$ the map induced by $c$
and the adjointness of restriction and base change;
if $c$ is clear we write $\mu = \mu_c$, i.e., we
drop $c$ from the notation. The map $\mu$ in the diagram is of this
form with $c$ given by the identification
$(M, g'_*a(g^*K))_X = ((g')^*M, a'(g^*K))_{X'}$
; the triangle involving $\mu$ is commutative by
Derived Categories of Schemes, Remark \ref{perfect-remark-multiplication-map}.

\medskip\noindent
Observe that
$$
\xymatrix{
(M, a(g_*g^*K))_X &
(f_*M, g_* g^*K)_Y \ar@{=}[l] &
(g^*f_*M, g^*K)_{Y'} \ar@{=}[l] \\
(M, g'_* a'(g^*K))_X \ar[u] &
((g')^*M, a'(g^*K))_{X'} \ar@{=}[l] &
(f'_*(g')^*M, g^*K)_{Y'} \ar@{=}[l] \ar[u]
}
$$
is commutative by the very definition of the transformation
$g'_* \circ a' \to a \circ g_*$. Letting $\mu'$ be as above
corresponding to the identification
$(f_*M, g_*g^*K)_X = (g^*f_*M, g^*K)_{Y'}$, then the
hexagon commutes as well. Thus it suffices to show that
$\beta$ is equal to the composition of
$(f_*M, K)_Y \otimes A' \to (f_*M, g_*g^*K)_X \otimes A'$
and $\mu'$. To do this, it suffices to prove the two induced maps
$(f_*M, K)_Y \to (g^*f_*M, g^*K)_{Y'}$ are the same.
In other words, it suffices to show the diagram
$$
\xymatrix{
R\Hom_A(E, K) \ar[rr]_{\text{induced by }\beta} \ar[rd] & &
R\Hom_{A'}(E \otimes_A^\mathbf{L} A', K \otimes_A^\mathbf{L} A') \\
& R\Hom_A(E, K \otimes_A^\mathbf{L} A') \ar[ru]
}
$$
commutes for all $E, K \in D(A)$. Since this is how $\beta$ is constructed in
More on Algebra, Section \ref{more-algebra-section-base-change-RHom}
the proof is complete.
\end{proof}








\section{Right adjoint of pushforward and trace maps}
\label{section-trace}

\noindent
Let $f : X \to Y$ be a morphism of quasi-compact and quasi-separated
schemes. Let $a : D_\QCoh(\mathcal{O}_Y) \to D_\QCoh(\mathcal{O}_X)$
be the right adjoint as in Lemma \ref{lemma-twisted-inverse-image}. By
Categories, Section \ref{categories-section-adjoint} we obtain a
transformation of functors
$$
\text{Tr}_f : Rf_* \circ a \longrightarrow \text{id}
$$
The corresponding map $\text{Tr}_{f, K} : Rf_*a(K) \longrightarrow K$
for $K \in D_\QCoh(\mathcal{O}_Y)$ is sometimes called the {\it trace map}.
This is the map which has the property that the bijection
$$
\Hom_X(L, a(K)) \longrightarrow \Hom_Y(Rf_*L, K)
$$
for $L \in D_\QCoh(\mathcal{O}_X)$ which characterizes the right adjoint
is given by
$$
\varphi \longmapsto \text{Tr}_{f, K} \circ Rf_*\varphi
$$
The map (\ref{equation-sheafy-trace})
$$
Rf_*R\SheafHom_{\mathcal{O}_X}(L, a(K))
\longrightarrow
R\SheafHom_{\mathcal{O}_Y}(Rf_*L, K)
$$
comes about by composition with $\text{Tr}_{f, K}$.
Every trace map we are going to consider in this section will be a
special case of this trace map. Before we discuss some special cases
we show that formation of the trace map commutes with base change.

\begin{lemma}[Trace map and base change]
\label{lemma-trace-map-and-base-change}
Suppose we have a diagram (\ref{equation-base-change}) where $f$ and $g$
are tor independent. Then the maps
$1 \star \text{Tr}_f : Lg^* \circ Rf_* \circ a \to Lg^*$ and
$\text{Tr}_{f'} \star 1 : Rf'_* \circ a' \circ Lg^* \to Lg^*$
agree via the base change maps
$\beta : Lg^* \circ Rf_* \to Rf'_* \circ L(g')^*$
(Cohomology, Remark \ref{cohomology-remark-base-change})
and $\alpha : L(g')^* \circ a \to a' \circ Lg^*$
(\ref{equation-base-change-map}).
More precisely, the diagram
$$
\xymatrix{
Lg^* \circ Rf_* \circ a
\ar[d]_{\beta \star 1} \ar[r]_-{1 \star \text{Tr}_f} &
Lg^* \\
Rf'_* \circ L(g')^* \circ a \ar[r]^{1 \star \alpha} &
Rf'_* \circ a' \circ Lg^* \ar[u]_{\text{Tr}_{f'} \star 1}
}
$$
of transformations of functors commutes.
\end{lemma}

\begin{proof}
In this proof we write $f_*$ for $Rf_*$ and $g^*$ for $Lg^*$ and we
drop $\star$ products with identities as one can figure out which ones
to add as long as the source and target of the transformation is known.
Recall that $\beta : g^* \circ f_* \to f'_* \circ (g')^*$ is an isomorphism
and that $\alpha$ is defined using
the isomorphism $\beta^\vee : g'_* \circ a' \to a \circ g_*$
which is the adjoint of $\beta$, see Lemma \ref{lemma-flat-precompose-pus}
and its proof. First we note that the top horizontal arrow
of the diagram in the lemma is equal to the composition
$$
g^* \circ f_* \circ a \to
g^* \circ f_* \circ a \circ g_* \circ g^* \to
g^* \circ g_* \circ g^* \to g^*
$$
where the first arrow is the unit for $(g^*, g_*)$, the second arrow
is $\text{Tr}_f$, and the third arrow is the counit for $(g^*, g_*)$.
This is a simple consequence of the fact that the composition
$g^* \to g^* \circ g_* \circ g^* \to g^*$ of unit and counit is the identity.
Consider the diagram
$$
\xymatrix{
& g^* \circ f_* \circ a \ar[ld]_\beta \ar[d] \ar[r]_{\text{Tr}_f} & g^* \\
f'_* \circ (g')^* \circ a \ar[dr] &
g^* \circ f_* \circ a \circ g_* \circ g^* \ar[d]_\beta \ar[ru] &
g^* \circ f_* \circ g'_* \circ a' \circ g^* \ar[l]_{\beta^\vee} \ar[d]_\beta &
f'_* \circ a' \circ g^* \ar[lu]_{\text{Tr}_{f'}} \\
& f'_* \circ (g')^* \circ a \circ g_* \circ g^* &
f'_* \circ (g')^* \circ g'_* \circ a' \circ g^* \ar[ru] \ar[l]_{\beta^\vee}
}
$$
In this diagram the two squares commute 
Categories, Lemma \ref{categories-lemma-properties-2-cat-cats}
or more simply the discussion preceding
Categories, Definition \ref{categories-definition-horizontal-composition}.
The triangle commutes by the discussion above. By
Categories, Lemma
\ref{categories-lemma-transformation-between-functors-and-adjoints}
the square
$$
\xymatrix{
g^* \circ f_* \circ g'_* \circ a' \ar[d]_{\beta^\vee} \ar[r]_-\beta &
f'_* \circ (g')^* \circ g'_* \circ a' \ar[d] \\
g^* \circ f_* \circ a \circ g_* \ar[r] &
\text{id}
}
$$
commutes which implies the pentagon in the big diagram commutes.
Since $\beta$ and $\beta^\vee$ are isomorphisms, and since going on
the outside of the big diagram equals
$\text{Tr}_f \circ \alpha \circ \beta$ by definition this proves the lemma.
\end{proof}

\noindent
Let $f : X \to Y$ be a morphism of quasi-compact and quasi-separated
schemes. Let $a : D_\QCoh(\mathcal{O}_Y) \to D_\QCoh(\mathcal{O}_X)$
be the right adjoint of $Rf_*$ as in
Lemma \ref{lemma-twisted-inverse-image}. By
Categories, Section \ref{categories-section-adjoint} we obtain a
transformation of functors
$$
\eta_f : \text{id} \to  a \circ Rf_*
$$
which is called the unit of the adjunction.

\begin{lemma}
\label{lemma-unit-and-base-change}
Suppose we have a diagram (\ref{equation-base-change}) where $f$ and $g$
are tor independent. Then the maps
$1 \star \eta_f : L(g')^* \to L(g')^* \circ a \circ Rf_*$ and
$\eta_{f'} \star 1 : L(g')^* \to a' \circ Rf'_* \circ L(g')^*$
agree via the base change maps
$\beta : Lg^* \circ Rf_* \to Rf'_* \circ L(g')^*$
(Cohomology, Remark \ref{cohomology-remark-base-change})
and $\alpha : L(g')^* \circ a \to a' \circ Lg^*$
(\ref{equation-base-change-map}).
More precisely, the diagram
$$
\xymatrix{
L(g')^* \ar[r]_-{1 \star \eta_f} \ar[d]_{\eta_{f'} \star 1} &
L(g')^* \circ a \circ Rf_* \ar[d]^\alpha \\
a' \circ Rf'_* \circ L(g')^* &
a' \circ Lg^* \circ Rf_* \ar[l]_-\beta
}
$$
of transformations of functors commutes.
\end{lemma}

\begin{proof}
This proof is dual to the proof of Lemma \ref{lemma-trace-map-and-base-change}.
In this proof we write $f_*$ for $Rf_*$ and $g^*$ for $Lg^*$ and we
drop $\star$ products with identities as one can figure out which ones
to add as long as the source and target of the transformation is known.
Recall that $\beta : g^* \circ f_* \to f'_* \circ (g')^*$ is an isomorphism
and that $\alpha$ is defined using
the isomorphism $\beta^\vee : g'_* \circ a' \to a \circ g_*$
which is the adjoint of $\beta$, see Lemma \ref{lemma-flat-precompose-pus}
and its proof. First we note that the left vertical arrow
of the diagram in the lemma is equal to the composition
$$
(g')^* \to (g')^* \circ g'_* \circ (g')^* \to
(g')^* \circ g'_* \circ a' \circ f'_* \circ (g')^* \to
a' \circ f'_* \circ (g')^*
$$
where the first arrow is the unit for $((g')^*, g'_*)$, the second arrow
is $\eta_{f'}$, and the third arrow is the counit for $((g')^*, g'_*)$.
This is a simple consequence of the fact that the composition
$(g')^* \to (g')^* \circ (g')_* \circ (g')^* \to (g')^*$
of unit and counit is the identity. Consider the diagram
$$
\xymatrix{
& (g')^* \circ a \circ f_* \ar[r] &
(g')^* \circ a \circ g_* \circ g^* \circ f_*
\ar[ld]_\beta \\
(g')^* \ar[ru]^{\eta_f} \ar[dd]_{\eta_{f'}} \ar[rd] &
(g')^* \circ a \circ g_* \circ f'_* \circ (g')^* &
(g')^* \circ g'_* \circ a' \circ g^* \circ f_*
\ar[u]_{\beta^\vee} \ar[ld]_\beta \ar[d] \\
& (g')^* \circ g'_* \circ a' \circ f'_* \circ (g')^*
\ar[ld] \ar[u]_{\beta^\vee} &
a' \circ g^* \circ f_* \ar[lld]^\beta \\
a' \circ f'_* \circ (g')^*
}
$$
In this diagram the two squares commute 
Categories, Lemma \ref{categories-lemma-properties-2-cat-cats}
or more simply the discussion preceding
Categories, Definition \ref{categories-definition-horizontal-composition}.
The triangle commutes by the discussion above. By the dual of
Categories, Lemma
\ref{categories-lemma-transformation-between-functors-and-adjoints}
the square
$$
\xymatrix{
\text{id} \ar[r] \ar[d] &
g'_* \circ a' \circ g^* \circ f_* \ar[d]^\beta \\
g'_* \circ a' \circ g^* \circ f_* \ar[r]^{\beta^\vee} &
a \circ g_* \circ f'_* \circ (g')^*
}
$$
commutes which implies the pentagon in the big diagram commutes.
Since $\beta$ and $\beta^\vee$ are isomorphisms, and since going on
the outside of the big diagram equals
$\beta \circ \alpha \circ \eta_f$ by definition this proves the lemma.
\end{proof}

\begin{example}
\label{example-trace-affine}
Let $A \to B$ be a ring map. Let $Y = \Spec(A)$ and $X = \Spec(B)$
and $f : X \to Y$ the morphism corresponding to $A \to B$. As seen
in Example \ref{example-affine-twisted-inverse-image}
the right adjoint of
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$
sends an object $K$ of $D(A) = D_\QCoh(\mathcal{O}_Y)$ to $R\Hom(B, K)$ in
$D(B) = D_\QCoh(\mathcal{O}_X)$. The trace map is the map
$$
\text{Tr}_{f, K} : R\Hom(B, K) \longrightarrow R\Hom(A, K) = K
$$
induced by the $A$-module map $A \to B$.
\end{example}




\section{Right adjoint of pushforward and pullback}
\label{section-compare-with-pullback}

\noindent
Let $f : X \to Y$ be a morphism of quasi-compact and quasi-separated
schemes. Let $a$ be the right adjoint of pushforward as in
Lemma \ref{lemma-twisted-inverse-image}. For $K, L \in D_\QCoh(\mathcal{O}_Y)$
there is a canonical map
$$
Lf^*K \otimes^\mathbf{L}_{\mathcal{O}_X} a(L)
\longrightarrow
a(K \otimes_{\mathcal{O}_Y}^\mathbf{L} L)
$$
Namely, this map is adjoint to a map
$$
Rf_*(Lf^*K \otimes^\mathbf{L}_{\mathcal{O}_X} a(L)) =
K \otimes^\mathbf{L}_{\mathcal{O}_Y} Rf_*(a(L))
\longrightarrow
K \otimes^\mathbf{L}_{\mathcal{O}_Y} L
$$
(equality by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-cohomology-base-change})
for which we use the trace map $Rf_*a(L) \to L$.
When $L = \mathcal{O}_Y$ we obtain a map
\begin{equation}
\label{equation-compare-with-pullback}
Lf^*K \otimes^\mathbf{L}_{\mathcal{O}_X} a(\mathcal{O}_Y) \longrightarrow a(K)
\end{equation}
functorial in $K$ and compatible with distinguished triangles.

\begin{lemma}
\label{lemma-compare-with-pullback-perfect}
Let $f : X \to Y$ be a morphism of quasi-compact and quasi-separated
schemes. The map
$Lf^*K \otimes^\mathbf{L}_{\mathcal{O}_X} a(L) \to
a(K \otimes_{\mathcal{O}_Y}^\mathbf{L} L)$
defined above for $K, L \in D_\QCoh(\mathcal{O}_Y)$
is an isomorphism if $K$ is perfect. In particular,
(\ref{equation-compare-with-pullback}) is an isomorphism if $K$ is perfect.
\end{lemma}

\begin{proof}
Let $K^\vee$ be the ``dual'' to $K$, see
Cohomology, Lemma \ref{cohomology-lemma-dual-perfect-complex}.
For $M \in D_\QCoh(\mathcal{O}_X)$ we have
\begin{align*}
\Hom_{D(\mathcal{O}_Y)}(Rf_*M, K \otimes^\mathbf{L}_{\mathcal{O}_Y} L)
& =
\Hom_{D(\mathcal{O}_Y)}(
Rf_*M \otimes^\mathbf{L}_{\mathcal{O}_Y} K^\vee, L) \\
& =
\Hom_{D(\mathcal{O}_X)}(
M \otimes^\mathbf{L}_{\mathcal{O}_X} Lf^*K^\vee, a(L)) \\
& =
\Hom_{D(\mathcal{O}_X)}(M,
Lf^*K \otimes^\mathbf{L}_{\mathcal{O}_X} a(L))
\end{align*}
Second equality by the definition of $a$ and the projection formula
(Cohomology, Lemma \ref{cohomology-lemma-projection-formula-perfect})
or the more general Derived Categories of Schemes, Lemma
\ref{perfect-lemma-cohomology-base-change}.
Hence the result by the Yoneda lemma.
\end{proof}

\begin{lemma}
\label{lemma-restriction-compare-with-pullback}
Suppose we have a diagram (\ref{equation-base-change}) where $f$ and $g$
are tor independent. Let $K \in D_\QCoh(\mathcal{O}_Y)$. The diagram
$$
\xymatrix{
L(g')^*(Lf^*K \otimes^\mathbf{L}_{\mathcal{O}_X} a(\mathcal{O}_Y))
\ar[r] \ar[d] & L(g')^*a(K) \ar[d] \\
L(f')^*Lg^*K \otimes_{\mathcal{O}_{X'}}^\mathbf{L} a'(\mathcal{O}_{Y'})
\ar[r] & a'(Lg^*K)
}
$$
commutes where the horizontal arrows are the maps
(\ref{equation-compare-with-pullback}) for $K$ and $Lg^*K$
and the vertical maps are constructed using
Cohomology, Remark \ref{cohomology-remark-base-change} and
(\ref{equation-base-change-map}).
\end{lemma}

\begin{proof}
In this proof we will write $f_*$ for $Rf_*$ and $f^*$ for $Lf^*$, etc,
and we will write $\otimes$ for $\otimes^\mathbf{L}_{\mathcal{O}_X}$, etc.
Let us write (\ref{equation-compare-with-pullback}) as the composition
\begin{align*}
f^*K \otimes a(\mathcal{O}_Y)
& \to
a(f_*(f^*K \otimes a(\mathcal{O}_Y))) \\
& \leftarrow
a(K \otimes f_*a(\mathcal{O}_K)) \\
& \to
a(K \otimes \mathcal{O}_Y) \\
& \to
a(K)
\end{align*}
Here the first arrow is the unit $\eta_f$, the second arrow is $a$
applied to Cohomology, Equation
(\ref{cohomology-equation-projection-formula-map}) which is an
isomorphism by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-cohomology-base-change}, the third arrow is
$a$ applied to $\text{id}_K \otimes \text{Tr}_f$, and the fourth
arrow is $a$ applied to the isomorphism $K \otimes \mathcal{O}_Y = K$.
The proof of the lemma consists in showing that each of these
maps gives rise to a commutative square as in the statement of the lemma.
For $\eta_f$ and $\text{Tr}_f$ this is
Lemmas \ref{lemma-unit-and-base-change} and
\ref{lemma-trace-map-and-base-change}.
For the arrow using Cohomology, Equation
(\ref{cohomology-equation-projection-formula-map})
this is Cohomology, Remark \ref{cohomology-remark-compatible-with-diagram}.
For the multiplication map it is clear. This finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-compare-on-open}
Let $f : X \to Y$ be a proper morphism of Noetherian schemes. Let $V \subset Y$
be an open such that $f^{-1}(V) \to V$ is an isomorphism. Then for
$K \in D_\QCoh^+(\mathcal{O}_Y)$ the map (\ref{equation-compare-with-pullback})
restricts to an isomorphism over $f^{-1}(V)$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-proper-noetherian} the map (\ref{equation-sheafy}) is an
isomorphism for objects of $D_\QCoh^+(\mathcal{O}_Y)$. Hence
Lemma \ref{lemma-restriction-compare-with-pullback} tells us the
restriction of (\ref{equation-compare-with-pullback}) for $K$
to $f^{-1}(V)$ is the map (\ref{equation-compare-with-pullback})
for $K|_V$ and $f^{-1}(V) \to V$. Thus it suffices to show that
the map is an isomorphism when $f$ is the identity morphism. This is clear.
\end{proof}

\begin{lemma}
\label{lemma-transitivity-compare-with-pullback}
Let $f : X \to Y$ and $g : Y \to Z$ be composable morphisms of quasi-compact
and quasi-separated schemes and set $h = g \circ f$. Let $a, b, c$ be the
adjoints of Lemma \ref{lemma-twisted-inverse-image} for $f, g, h$.
For any $K \in D_\QCoh(\mathcal{O}_Z)$ the diagram
$$
\xymatrix{
Lf^*(Lg^*K \otimes_{\mathcal{O}_Y}^\mathbf{L}
b(\mathcal{O}_Z)) \otimes_{\mathcal{O}_X}^\mathbf{L} a(\mathcal{O}_Y)
\ar@{=}[d] \ar[r] &
a(Lg^*K \otimes_{\mathcal{O}_Y}^\mathbf{L} b(\mathcal{O}_Z)) \ar[r] &
a(b(K)) \ar@{=}[d] \\
Lh^*K \otimes_{\mathcal{O}_X}^\mathbf{L} Lf^*b(\mathcal{O}_Z)
\otimes_{\mathcal{O}_X}^\mathbf{L} a(\mathcal{O}_Y) \ar[r] &
Lh^*K \otimes_{\mathcal{O}_X}^\mathbf{L} c(\mathcal{O}_Z) \ar[r] &
c(K)
}
$$
is commutative where the arrows are (\ref{equation-compare-with-pullback})
and we have used $Lh^* = Lf^* \circ Lg^*$ and $c = a \circ b$.
\end{lemma}

\begin{proof}
In this proof we will write $f_*$ for $Rf_*$ and $f^*$ for $Lf^*$, etc,
and we will write $\otimes$ for $\otimes^\mathbf{L}_{\mathcal{O}_X}$, etc.
The composition of the top arrows is adjoint to a map
$$
g_*f_*(f^*(g^*K \otimes b(\mathcal{O}_Z)) \otimes a(\mathcal{O}_Y)) \to K
$$
The left hand side is equal to
$K \otimes g_*f_*(f^*b(\mathcal{O}_Z) \otimes a(\mathcal{O}_Y))$ by
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-cohomology-base-change}
and inspection of the definitions shows the map comes from the map
$$
g_*f_*(f^*b(\mathcal{O}_Z) \otimes a(\mathcal{O}_Y))
\xleftarrow{g_*\epsilon}
g_*(b(\mathcal{O}_Z) \otimes f_*a(\mathcal{O}_Y)) \xrightarrow{g_*\alpha}
g_*(b(\mathcal{O}_Z)) \xrightarrow{\beta} \mathcal{O}_Z
$$
tensored with $\text{id}_K$. Here $\epsilon$ is the isomorphism from
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-cohomology-base-change} and
$\beta$ comes from the counit map
$g_*b \to \text{id}$. Similarly, the composition of the lower
horizontal arrows is adjoint to $\text{id}_K$ tensored with the composition 
$$
g_*f_*(f^*b(\mathcal{O}_Z) \otimes a(\mathcal{O}_Y)) \xrightarrow{g_*f_*\delta}
g_*f_*(ab(\mathcal{O}_Z)) \xrightarrow{g_*\gamma}
g_*(b(\mathcal{O}_Z)) \xrightarrow{\beta}
\mathcal{O}_Z
$$
where $\gamma$ comes from the counit map $f_*a \to \text{id}$
and $\delta$ is the map whose adjoint is the composition
$$
f_*(f^*b(\mathcal{O}_Z) \otimes a(\mathcal{O}_Y))
\xleftarrow{\epsilon}
b(\mathcal{O}_Z) \otimes f_*a(\mathcal{O}_Y) \xrightarrow{\alpha}
b(\mathcal{O}_Z)
$$
By general properties of adjoint functors, adjoint maps, and counits
(see Categories, Section \ref{categories-section-adjoint})
we have $\gamma \circ f_*\delta = \alpha \circ \epsilon^{-1}$ as desired.
\end{proof}





\section{Right adjoint of pushforward for closed immersions}
\label{section-sections-with-exact-support}

\noindent
Let $i : (Z, \mathcal{O}_Z) \to (X, \mathcal{O}_X)$ be a morphism
of ringed spaces such that $i$ is a homeomorphism onto a closed
subset and such that $i^\sharp : \mathcal{O}_X \to i_*\mathcal{O}_Z$
is surjective. (For example a closed immersion of schemes.)
Let $\mathcal{I} = \Ker(i^\sharp)$. For a sheaf
of $\mathcal{O}_X$-modules $\mathcal{F}$ the sheaf
$$
\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_Z, \mathcal{F})
$$
a sheaf of $\mathcal{O}_X$-modules annihilated by $\mathcal{I}$.
Hence by Modules, Lemma \ref{modules-lemma-i-star-equivalence}
there is a sheaf of $\mathcal{O}_Z$-modules,
which we will denote $\SheafHom(\mathcal{O}_Z, \mathcal{F})$,
such that
$$
i_*\SheafHom(\mathcal{O}_Z, \mathcal{F}) =
\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_Z, \mathcal{F})
$$
as $\mathcal{O}_X$-modules. We spell out what this means.

\begin{lemma}
\label{lemma-compute-sheaf-with-exact-support}
With notation as above. The functor $\SheafHom(\mathcal{O}_Z, -)$ is a
right adjoint to the functor
$i_* : \textit{Mod}(\mathcal{O}_Z) \to \textit{Mod}(\mathcal{O}_X)$.
For $V \subset Z$ open we have
$$
\Gamma(V, \SheafHom(\mathcal{O}_Z, \mathcal{F})) =
\{s \in \Gamma(U, \mathcal{F}) \mid \mathcal{I}s = 0\}
$$
where $U \subset X$ is an open whose intersection with $Z$ is $V$.
\end{lemma}

\begin{proof}
Let $\mathcal{G}$ be a sheaf of $\mathcal{O}_Z$-modules. Then
$$
\Hom_{\mathcal{O}_X}(i_*\mathcal{G}, \mathcal{F}) =
\Hom_{i_*\mathcal{O}_Z}(i_*\mathcal{G},
\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_Z, \mathcal{F})) =
\Hom_{\mathcal{O}_Z}(\mathcal{G}, \SheafHom(\mathcal{O}_Z, \mathcal{F}))
$$
The first equality by
Modules, Lemma \ref{modules-lemma-adjoint-tensor-restrict}
and the second by the fully faithfulness of $i_*$, see
Modules, Lemma \ref{modules-lemma-i-star-equivalence}.
The description of sections is left to the reader.
\end{proof}

\noindent
The functor
$$
\textit{Mod}(\mathcal{O}_X)
\longrightarrow
\textit{Mod}(\mathcal{O}_Z),
\quad
\mathcal{F} \longmapsto \SheafHom(\mathcal{O}_Z, \mathcal{F})
$$
is left exact and has a derived extension
$$
R\SheafHom(\mathcal{O}_Z, -) : D(\mathcal{O}_X) \to D(\mathcal{O}_Z).
$$

\begin{lemma}
\label{lemma-sheaf-with-exact-support-adjoint}
With notation as above. The functor $R\SheafHom(\mathcal{O}_Z, -)$
is the right adjoint of the functor
$Ri_* : D(\mathcal{O}_Z) \to D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
This is a consequence of the fact that $i_*$ and
$\SheafHom(\mathcal{O}_Z, -)$ are adjoint functors by
Lemma \ref{lemma-compute-sheaf-with-exact-support}. See
Derived Categories, Lemma \ref{derived-lemma-derived-adjoint-functors}.
\end{proof}

\begin{lemma}
\label{lemma-sheaf-with-exact-support-ext}
With notation as above. We have
$$
Ri_*R\SheafHom(\mathcal{O}_Z, K) =
R\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_Z, K)
$$
in $D(\mathcal{O}_X)$ for all $K$ in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
This is immediate from the construction of the functor
$R\SheafHom(\mathcal{O}_Z, -)$.
\end{proof}

\begin{lemma}
\label{lemma-sheaf-with-exact-support-internal-home}
With notation as above. For $M \in D(\mathcal{O}_Z)$ we have
$$
R\SheafHom_{\mathcal{O}_X}(Ri_*M, K) =
Ri_*R\SheafHom_{\mathcal{O}_Z}(M, R\SheafHom(\mathcal{O}_Z, K))
$$
in $D(\mathcal{O}_Z)$ for all $K$ in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
This is immediate from the construction of the functor
$R\SheafHom(\mathcal{O}_Z, -)$ and the fact that if
$\mathcal{K}^\bullet$ is a K-injective complex of
$\mathcal{O}_X$-modules, then $\SheafHom(\mathcal{O}_Z, \mathcal{K}^\bullet)$
is a K-injective complex of $\mathcal{O}_Z$-modules, see
Derived Categories, Lemma \ref{derived-lemma-adjoint-preserve-K-injectives}.
\end{proof}

\begin{lemma}
\label{lemma-sheaf-with-exact-support-quasi-coherent}
Let $i : Z \to X$ be a pseudo-coherent closed immersion of schemes
(any closed immersion if $X$ is locally Noetherian).
Then
\begin{enumerate}
\item $R\SheafHom(\mathcal{O}_Z, -)$ maps $D^+_\QCoh(\mathcal{O}_X)$
into $D^+_\QCoh(\mathcal{O}_Z)$, and
\item if $X = \Spec(A)$ and $Z = \Spec(B)$, then the diagram
$$
\xymatrix{
D^+(B) \ar[r] & D_\QCoh^+(\mathcal{O}_Z) \\
D^+(A) \ar[r] \ar[u]^{R\Hom(B, -)} &
D_\QCoh^+(\mathcal{O}_X) \ar[u]_{R\SheafHom(\mathcal{O}_Z, -)}
}
$$
is commutative.
\end{enumerate}
\end{lemma}

\begin{proof}
To explain the parenthetical remark, if $X$ is locally Noetherian, then
$i$ is pseudo-coherent by
More on Morphisms, Lemma \ref{more-morphisms-lemma-Noetherian-pseudo-coherent}.

\medskip\noindent
Let $K$ be an object of $D^+_\QCoh(\mathcal{O}_X)$. To prove (1), by
Morphisms, Lemma \ref{morphisms-lemma-i-star-equivalence}
it suffices to show that $i_*$ applied to
$H^n(R\SheafHom(\mathcal{O}_Z, K))$ produces a
quasi-coherent module on $X$. By
Lemma \ref{lemma-sheaf-with-exact-support-ext}
this means we have to show that
$R\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_Z, K)$
is in $D_\QCoh(\mathcal{O}_X)$. Since $i$ is pseudo-coherent
the sheaf $\mathcal{O}_Z$ is a pseudo-coherent $\mathcal{O}_X$-module.
Hence the result follows from
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-internal-hom}.

\medskip\noindent
Assume $X = \Spec(A)$ and $Z = \Spec(B)$ as in (2).
Let $I^\bullet$ be a bounded below complex of injective $A$-modules
representing an object $K$ of $D^+(A)$.
Then we know that $R\Hom(B, K) = \Hom_A(B, I^\bullet)$ viewed
as a complex of $B$-modules. Choose a quasi-isomorphism
$$
\widetilde{I^\bullet} \longrightarrow \mathcal{I}^\bullet
$$
where $\mathcal{I}^\bullet$ is a bounded below complex of injective
$\mathcal{O}_X$-modules. It follows from the description of
the functor $\SheafHom(\mathcal{O}_Z, -)$ in
Lemma \ref{lemma-compute-sheaf-with-exact-support}
that there is a map
$$
\Hom_A(B, I^\bullet)
\longrightarrow
\Gamma(Z, \SheafHom(\mathcal{O}_Z, \mathcal{I}^\bullet))
$$
Observe that $\SheafHom(\mathcal{O}_Z, \mathcal{I}^\bullet)$
represents $R\SheafHom(\mathcal{O}_Z, \widetilde{K})$.
Applying the universal property of the $\widetilde{\ }$ functor we
obtain a map
$$
\widetilde{\Hom_A(B, I^\bullet)}
\longrightarrow
R\SheafHom(\mathcal{O}_Z, \widetilde{K})
$$
in $D(\mathcal{O}_Z)$. We may check that this map is an isomorphism in
$D(\mathcal{O}_Z)$ after applying $i_*$. However, once we apply
$i_*$ we obtain the isomorphism of Derived Categories of Schemes,
Lemma \ref{perfect-lemma-quasi-coherence-internal-hom}
via the identification of
Lemma \ref{lemma-sheaf-with-exact-support-ext}.
\end{proof}

\begin{lemma}
\label{lemma-sheaf-with-exact-support-coherent}
Let $i : Z \to X$ be a closed immersion of schemes.
Assume $X$ is a locally Noetherian.
Then $R\SheafHom(\mathcal{O}_Z, -)$ maps $D^+_{\textit{Coh}}(\mathcal{O}_X)$
into $D^+_{\textit{Coh}}(\mathcal{O}_Z)$.
\end{lemma}

\begin{proof}
The question is local on $X$, hence we may assume that $X$ is affine.
Say $X = \Spec(A)$ and $Z = \Spec(B)$ with $A$ Noetherian and
$A \to B$ surjective. In this case, we can apply
Lemma \ref{lemma-sheaf-with-exact-support-quasi-coherent}
to translate the question into algebra.
The corresponding algebra result is a consequence of
Dualizing Complexes, Lemma \ref{dualizing-lemma-exact-support-coherent}.
\end{proof}

\begin{lemma}
\label{lemma-twisted-inverse-image-closed}
Let $X$ be a quasi-compact and quasi-separated scheme.
Let $i : Z \to X$ be a pseudo-coherent closed immersion
(if $X$ is Noetherian, then any closed immersion is pseudo-coherent).
Let $a : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Z)$ be the
right adjoint to $Ri_*$. Then there is a functorial isomorphism
$$
a(K) = R\SheafHom(\mathcal{O}_Z, K)
$$
for $K \in D_\QCoh^+(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
(The parenthetical statement follows from More on Morphisms, Lemma
\ref{more-morphisms-lemma-Noetherian-pseudo-coherent}.)
By Lemma \ref{lemma-sheaf-with-exact-support-adjoint}
the functor $R\SheafHom(\mathcal{O}_Z, -)$ is a right adjoint
to $Ri_* : D(\mathcal{O}_Z) \to D(\mathcal{O}_X)$. Moreover,
by Lemma \ref{lemma-sheaf-with-exact-support-quasi-coherent}
and Lemma \ref{lemma-twisted-inverse-image-bounded-below}
both $R\SheafHom(\mathcal{O}_Z, -)$ and $a$ map
$D_\QCoh^+(\mathcal{O}_X)$ into $D_\QCoh^+(\mathcal{O}_Z)$.
Hence we obtain the isomorphism by uniqueness of adjoint
functors.
\end{proof}

\begin{example}
\label{example-trace-closed-immersion}
If $i : Z \to X$ is closed immersion of Noetherian schemes, then
the diagram
$$
\xymatrix{
i_*a(K) \ar[rr]_-{\text{Tr}_{i, K}} \ar@{=}[d] & &
K \ar@{=}[d] \\
i_*R\SheafHom(\mathcal{O}_Z, K) \ar@{=}[r] &
R\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_Z, K)
\ar[r] & K
}
$$
is commutative for $K \in D_\QCoh^+(\mathcal{O}_X)$.
Here the horizontal equality sign is
Lemma \ref{lemma-sheaf-with-exact-support-ext} and the
lower horizontal arrow is induced
by the map $\mathcal{O}_X \to i_*\mathcal{O}_Z$. The commutativity
of the diagram is a consequence of
Lemma \ref{lemma-twisted-inverse-image-closed}.
\end{example}




\section{Right adjoint of pushforward for closed immersions and base change}
\label{section-sections-with-exact-support-base-change}

\noindent
Consider a cartesian diagram of schemes
$$
\xymatrix{
Z' \ar[r]_{i'} \ar[d]_g & X' \ar[d]^f \\
Z \ar[r]^i & X
}
$$
where $i$ is a closed immersion. If $Z$ and $X'$ are
tor independent over $X$, then there is a canonical
base change map
\begin{equation}
\label{equation-base-change-exact-support}
Lg^*R\SheafHom(\mathcal{O}_Z, K)
\longrightarrow
R\SheafHom(\mathcal{O}_{Z'}, Lf^*K)
\end{equation}
in $D(\mathcal{O}_{Z'})$ functorial for $K$ in $D(\mathcal{O}_X)$.
Namely, by adjointness of Lemma \ref{lemma-sheaf-with-exact-support-adjoint}
such an arrow is the same thing as a map
$$
Ri'_*Lg^*R\SheafHom(\mathcal{O}_Z, K)
\longrightarrow
Lf^*K
$$
in $D(\mathcal{O}_{X'})$. By tor independence we have
$Ri'_* \circ Lg^* = Lf^* \circ Ri_*$ (see
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-compare-base-change-closed-immersion}).
Thus this is the same thing as a map
$$
Lf^*Ri_*R\SheafHom(\mathcal{O}_Z, K)
\longrightarrow
Lf^*K
$$
For this we can use $Lf^*(can)$ where
$can : Ri_* R\SheafHom(\mathcal{O}_Z, K) \to K$ is the
counit of the adjunction.

\begin{lemma}
\label{lemma-check-base-change-is-iso}
In the situation above, the map (\ref{equation-base-change-exact-support})
is an isomorphism if and only if the base change map
$$
Lf^*R\SheafHom_{\mathcal{O}_X}(\mathcal{O}_Z, K)
\longrightarrow
R\SheafHom_{\mathcal{O}_{X'}}(\mathcal{O}_{Z'}, Lf^*K)
$$
of Cohomology, Remark \ref{cohomology-remark-prepare-fancy-base-change}
is an isomorphism.
\end{lemma}

\begin{proof}
The statement makes sense because $\mathcal{O}_{Z'} = Lf^*\mathcal{O}_Z$
by the assumed tor independence.
Since $i'_*$ is exact and faithful we see that it suffices to show
the map (\ref{equation-base-change-exact-support})
is an isomorphism after applying $Ri'_*$. Since
$Ri'_* \circ Lg^* = Lf^* \circ Ri_*$ by the assumed tor independence and
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-compare-base-change-closed-immersion}
we obtain a map
$$
Lf^*Ri_*R\SheafHom(\mathcal{O}_Z, K)
\longrightarrow
Ri'_*R\SheafHom(\mathcal{O}_{Z'}, Lf^*K)
$$
whose source and target are as in the statement of the lemma by
Lemma \ref{lemma-sheaf-with-exact-support-ext}. We omit the
verification that this is the same map as the one constructed
in Cohomology, Remark \ref{cohomology-remark-prepare-fancy-base-change}.
\end{proof}

\begin{lemma}
\label{lemma-flat-bc-sheaf-with-exact-support}
In the situation above, assume $f$ is flat and $i$ pseudo-coherent.
Then (\ref{equation-base-change-exact-support}) is an isomorphism
for $K$ in $D^+_\QCoh(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
First proof. To prove this map is an isomorphism, we may work locally.
Hence we may assume $X$, $X'$, $Z$, $Z'$ are affine, say corresponding
to the rings $A$, $A'$, $B$, $B'$. Then $B$ and $A'$ are tor independent
over $A$. By Lemma \ref{lemma-check-base-change-is-iso} it suffices
to check that
$$
R\Hom_A(B, K) \otimes_A^\mathbf{L} A' =
R\Hom_{A'}(B', K \otimes_A^\mathbf{L} A')
$$
in $D(A')$ for all $K \in D^+(A)$. Here we use
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-internal-hom}
and the fact that $B$, resp.\ $B'$ is pseudo-coherent as an
$A$-module, resp.\ $A'$-module
to compare derived hom on the level of rings and schemes.
The displayed equality follows from
More on Algebra, Lemma
\ref{more-algebra-lemma-internal-hom-evaluate-tensor-isomorphism}
part (3). See also the discussion in Dualizing Complexes, Section
\ref{dualizing-section-base-change-trivial-duality}.

\medskip\noindent
Second proof\footnote{This proof shows
it suffices to assume $K$ is in $D^+(\mathcal{O}_X)$.}.
Let $z' \in Z'$ with image $z \in Z$.
First show that (\ref{equation-base-change-exact-support})
on stalks at $z'$ induces the map
$$
R\Hom(\mathcal{O}_{Z, z}, K_z)
\otimes_{\mathcal{O}_{Z, x}}^\mathbf{L} \mathcal{O}_{Z', z'}
\longrightarrow
R\Hom(\mathcal{O}_{Z', z'},
K_z \otimes_{\mathcal{O}_{X, z}}^\mathbf{L} \mathcal{O}_{X', z'})
$$
from Dualizing Complexes, Equation (\ref{dualizing-equation-base-change}).
Namely, the constructions of these maps are identical.
Then apply Dualizing Complexes, Lemma \ref{dualizing-lemma-flat-bc-surjection}.
\end{proof}

\begin{lemma}
\label{lemma-sheaf-with-exact-support-tensor}
Let $i : Z \to X$ be a pseudo-coherent closed immersion of schemes.
Let $M \in D_\QCoh(\mathcal{O}_X)$ locally have tor-amplitude in $[a, \infty)$.
Let $K \in D_\QCoh^+(\mathcal{O}_X)$. Then there is a canonical isomorphism
$$
R\SheafHom(\mathcal{O}_Z, K) \otimes_{\mathcal{O}_Z}^\mathbf{L} Li^*M =
R\SheafHom(\mathcal{O}_Z, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)
$$
in $D(\mathcal{O}_Z)$.
\end{lemma}

\begin{proof}
A map from LHS to RHS is the same thing as a map
$$
Ri_*R\SheafHom(\mathcal{O}_Z, K) \otimes_{\mathcal{O}_X}^\mathbf{L} M
\longrightarrow
K \otimes_{\mathcal{O}_X}^\mathbf{L} M
$$
by Lemmas \ref{lemma-sheaf-with-exact-support-adjoint} and
\ref{lemma-sheaf-with-exact-support-ext}. For this map we take the
counit $Ri_*R\SheafHom(\mathcal{O}_Z, K) \to K$ tensored with $\text{id}_M$.
To see this map is an isomorphism under the hypotheses given,
translate into algebra using
Lemma \ref{lemma-sheaf-with-exact-support-quasi-coherent}
and then for example use More on Algebra, Lemma
\ref{more-algebra-lemma-internal-hom-evaluate-tensor-isomorphism} part (3).
Instead of using Lemma \ref{lemma-sheaf-with-exact-support-quasi-coherent}
you can look at stalks as in the second proof of
Lemma \ref{lemma-flat-bc-sheaf-with-exact-support}.
\end{proof}



\section{Right adjoint of pushforward for finite morphisms}
\label{section-duality-finite}

\noindent
If $i : Z \to X$ is a closed immersion of schemes, then there is
a right adjoint $\SheafHom(\mathcal{O}_Z, -)$ to the functor
$i_* : \textit{Mod}(\mathcal{O}_Z) \to \textit{Mod}(\mathcal{O}_X)$
whose derived extension $R\SheafHom(\mathcal{O}_Z, -)$
is the right adjoint to $Ri_* : D(\mathcal{O}_Z) \to D(\mathcal{O}_X)$. See
Section \ref{section-sections-with-exact-support}.
In the case of a finite morphism $f : Y \to X$ this strategy
cannot work, as the functor
$f_* : \textit{Mod}(\mathcal{O}_Y) \to \textit{Mod}(\mathcal{O}_X)$
is not exact in general and hence does not have a right adjoint.
A replacement is to consider the exact functor
$\textit{Mod}(f_*\mathcal{O}_Y) \to \textit{Mod}(\mathcal{O}_X)$
and consider the corresponding right adjoint and its derived
extension.

\medskip\noindent
Let $f : Y \to X$ be an affine morphism of schemes. For a sheaf
of $\mathcal{O}_X$-modules $\mathcal{F}$ the sheaf
$$
\SheafHom_{\mathcal{O}_X}(f_*\mathcal{O}_Y, \mathcal{F})
$$
is a sheaf of $f_*\mathcal{O}_Y$-modules. We obtain a functor
$\textit{Mod}(\mathcal{O}_X) \to \textit{Mod}(f_*\mathcal{O}_Y)$
which we will denote $\SheafHom(f_*\mathcal{O}_Y, -)$.

\begin{lemma}
\label{lemma-compute-sheafhom-affine}
With notation as above. The functor $\SheafHom(f_*\mathcal{O}_Y, -)$ is a
right adjoint to the restriction functor
$\textit{Mod}(f_*\mathcal{O}_Y) \to \textit{Mod}(\mathcal{O}_X)$.
For an affine open $U \subset X$ we have
$$
\Gamma(U, \SheafHom(f_*\mathcal{O}_Y, \mathcal{F})) =
\Hom_A(B, \mathcal{F}(U))
$$
where $A = \mathcal{O}_X(U)$ and $B = \mathcal{O}_Y(f^{-1}(U))$.
\end{lemma}

\begin{proof}
Adjointness follows from
Modules, Lemma \ref{modules-lemma-adjoint-tensor-restrict}.
As $f$ is affine we see that $f_*\mathcal{O}_Y$ is
the quasi-coherent sheaf corresponding to $B$ viewed
as an $A$-module. Hence the description of sections over $U$ follows from
Schemes, Lemma \ref{schemes-lemma-compare-constructions}.
\end{proof}

\noindent
The functor $\SheafHom(f_*\mathcal{O}_Y, -)$ is left exact. Let
$$
R\SheafHom(f_*\mathcal{O}_Y, -) :
D(\mathcal{O}_X)
\longrightarrow
D(f_*\mathcal{O}_Y)
$$
be its derived extension.

\begin{lemma}
\label{lemma-sheafhom-affine-adjoint}
With notation as above. The functor $R\SheafHom(f_*\mathcal{O}_Y, -)$
is the right adjoint of the functor $D(f_*\mathcal{O}_Y) \to D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Follows from Lemma \ref{lemma-compute-sheafhom-affine}
and
Derived Categories, Lemma \ref{derived-lemma-derived-adjoint-functors}.
\end{proof}

\begin{lemma}
\label{lemma-sheafhom-affine-ext}
With notation as above. The composition
$$
D(\mathcal{O}_X) \xrightarrow{R\SheafHom(f_*\mathcal{O}_Y, -)}
D(f_*\mathcal{O}_Y) \to D(\mathcal{O}_X)
$$
is the functor $K \mapsto R\SheafHom_{\mathcal{O}_X}(f_*\mathcal{O}_Y, K)$.
\end{lemma}

\begin{proof}
This is immediate from the construction.
\end{proof}

\begin{lemma}
\label{lemma-finite-twisted}
Let $f : Y \to X$ be a finite pseudo-coherent morphism of schemes
(a finite morphism of Noetherian schemes is pseudo-coherent).
The functor $R\SheafHom(f_*\mathcal{O}_Y, -)$ maps
$D_\QCoh^+(\mathcal{O}_X)$ into $D_\QCoh^+(f_*\mathcal{O}_Y)$.
If $X$ is quasi-compact and quasi-separated, then the diagram
$$
\xymatrix{
D_\QCoh^+(\mathcal{O}_X) \ar[rr]_a \ar[rd]_{R\SheafHom(f_*\mathcal{O}_Y, -)}
& & D_\QCoh^+(\mathcal{O}_Y) \ar[ld]^\Phi \\
& D_\QCoh^+(f_*\mathcal{O}_Y)
}
$$
is commutative, where $a$ is the right adjoint of
Lemma \ref{lemma-twisted-inverse-image} for $f$ and $\Phi$ is the equivalence
of Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-morphism-equivalence}.
\end{lemma}

\begin{proof}
(The parenthetical remark follows from More on Morphisms, Lemma
\ref{more-morphisms-lemma-Noetherian-pseudo-coherent}.)
Since $f$ is pseudo-coherent, the $\mathcal{O}_X$-module $f_*\mathcal{O}_Y$
is pseudo-coherent, see More on Morphisms, Lemma
\ref{more-morphisms-lemma-finite-pseudo-coherent}.
Thus $R\SheafHom(f_*\mathcal{O}_Y, -)$ maps
$D_\QCoh^+(\mathcal{O}_X)$ into
$D_\QCoh^+(f_*\mathcal{O}_Y)$, see
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-internal-hom}.
Then $\Phi \circ a$ and $R\SheafHom(f_*\mathcal{O}_Y, -)$
agree on $D_\QCoh^+(\mathcal{O}_X)$ because these functors are
both right adjoint to the restriction functor
$D_\QCoh^+(f_*\mathcal{O}_Y) \to D_\QCoh^+(\mathcal{O}_X)$. To see this
use Lemmas \ref{lemma-twisted-inverse-image-bounded-below} and
\ref{lemma-sheafhom-affine-adjoint}.
\end{proof}

\begin{remark}
\label{remark-trace-map-finite}
If $f : Y \to X$ is a finite morphism of Noetherian schemes, then the diagram
$$
\xymatrix{
Rf_*a(K) \ar[r]_-{\text{Tr}_{f, K}} \ar@{=}[d] & K \ar@{=}[d] \\
R\SheafHom_{\mathcal{O}_X}(f_*\mathcal{O}_Y, K) \ar[r] & K
}
$$
is commutative for $K \in D_\QCoh^+(\mathcal{O}_X)$. This follows
from Lemma \ref{lemma-finite-twisted}. The lower horizontal
arrow is induced by the map $\mathcal{O}_X \to f_*\mathcal{O}_Y$ and the
upper horizontal arrow is the trace map discussed in
Section \ref{section-trace}.
\end{remark}






\section{Right adjoint of pushforward for proper flat morphisms}
\label{section-proper-flat}

\noindent
For proper, flat, and finitely presented morphisms of quasi-compact
and quasi-separated schemes the right adjoint of pushforward
enjoys some remarkable properties.

\begin{lemma}
\label{lemma-proper-flat}
Let $Y$ be a quasi-compact and quasi-separated scheme.
Let $f : X \to Y$ be a morphism of schemes which is proper, flat, and
of finite presentation.
Let $a$ be the right adjoint for
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$ of
Lemma \ref{lemma-twisted-inverse-image}. Then $a$ commutes with direct sums.
\end{lemma}

\begin{proof}
Let $P$ be a perfect object of $D(\mathcal{O}_X)$. By
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-flat-proper-perfect-direct-image-general}
the complex $Rf_*P$ is perfect on $Y$.
Let $K_i$ be a family of objects of $D_\QCoh(\mathcal{O}_Y)$.
Then
\begin{align*}
\Hom_{D(\mathcal{O}_X)}(P, a(\bigoplus K_i))
& =
\Hom_{D(\mathcal{O}_Y)}(Rf_*P, \bigoplus K_i) \\
& =
\bigoplus \Hom_{D(\mathcal{O}_Y)}(Rf_*P, K_i) \\
& =
\bigoplus \Hom_{D(\mathcal{O}_X)}(P, a(K_i))
\end{align*}
because a perfect object is compact (Derived Categories of Schemes,
Proposition \ref{perfect-proposition-compact-is-perfect}).
Since $D_\QCoh(\mathcal{O}_X)$ has a perfect generator
(Derived Categories of Schemes, Theorem
\ref{perfect-theorem-bondal-van-den-Bergh})
we conclude that the map $\bigoplus a(K_i) \to a(\bigoplus K_i)$
is an isomorphism, i.e., $a$ commutes with direct sums.
\end{proof}

\begin{lemma}
\label{lemma-proper-flat-relative}
Let $Y$ be a quasi-compact and quasi-separated scheme.
Let $f : X \to Y$ be a morphism of schemes which is proper, flat, and
of finite presentation.
Let $a$ be the right adjoint for
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$ of
Lemma \ref{lemma-twisted-inverse-image}. Then
\begin{enumerate}
\item for every closed $T \subset Y$ if $Q \in D_\QCoh(Y)$ is supported on $T$,
then $a(Q)$ is supported on $f^{-1}(T)$,
\item for every open $V \subset Y$ and any $K \in D_\QCoh(\mathcal{O}_Y)$
the map (\ref{equation-sheafy}) is an isomorphism, and
\end{enumerate}
\end{lemma}

\begin{proof}
This follows from Lemmas \ref{lemma-when-sheafy},
\ref{lemma-proper-noetherian}, and
\ref{lemma-proper-flat}.
\end{proof}

\begin{lemma}
\label{lemma-compare-with-pullback-flat-proper}
Let $Y$ be a quasi-compact and quasi-separated scheme.
Let $f : X \to Y$ be a morphism of schemes which is proper, flat, and
of finite presentation.
The map (\ref{equation-compare-with-pullback}) is an isomorphism
for every object $K$ of $D_\QCoh(\mathcal{O}_Y)$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-proper-flat} we know that $a$ commutes
with direct sums. Hence the collection of objects of
$D_\QCoh(\mathcal{O}_Y)$ for which (\ref{equation-compare-with-pullback})
is an isomorphism is a strictly full, saturated, triangulated
subcategory of $D_\QCoh(\mathcal{O}_Y)$ which is moreover
preserved under taking direct sums. Since $D_\QCoh(\mathcal{O}_Y)$
is a module category (Derived Categories of Schemes, Theorem
\ref{perfect-theorem-DQCoh-is-Ddga}) generated by a single
perfect object (Derived Categories of Schemes, Theorem
\ref{perfect-theorem-bondal-van-den-Bergh})
we can argue as in
More on Algebra, Remark \ref{more-algebra-remark-P-resolution}
to see that it suffices to prove (\ref{equation-compare-with-pullback})
is an isomorphism for a single perfect object.
However, the result holds for perfect objects, see
Lemma \ref{lemma-compare-with-pullback-perfect}.
\end{proof}

\noindent
The following lemma shows that the base change map
(\ref{equation-base-change-map}) is an isomorphism
for proper, flat morphisms of finite presentation.
We will see in
Example \ref{example-base-change-wrong}
that this does not remain true for perfect proper morphisms;
in that case one has to make a tor independence condition.

\begin{lemma}
\label{lemma-proper-flat-base-change}
Let $g : Y' \to Y$ be a morphism of quasi-compact and quasi-separated schemes.
Let $f : X \to Y$ be a proper, flat morphism of finite presentation.
Then the base change map (\ref{equation-base-change-map}) is an isomorphism
for all $K \in D_\QCoh(\mathcal{O}_Y)$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-proper-flat-relative} formation of the
functors $a$ and $a'$ commutes with restriction to opens of $Y$ and $Y'$.
Hence we may assume $Y' \to Y$ is a morphism of affine schemes, see
Remark \ref{remark-check-over-affines}. In this
case the statement follows from Lemma \ref{lemma-more-base-change}.
\end{proof}

\begin{remark}
\label{remark-relative-dualizing-complex}
Let $Y$ be a quasi-compact and quasi-separated scheme.
Let $f : X \to Y$ be a proper, flat morphism of finite presentation.
Let $a$ be the adjoint of Lemma \ref{lemma-twisted-inverse-image} for $f$.
In this situation, $\omega_{X/Y}^\bullet = a(\mathcal{O}_Y)$
is sometimes called the {\it relative dualizing complex}. By
Lemma \ref{lemma-compare-with-pullback-flat-proper}
there is a functorial isomorphism
$a(K) = Lf^*K \otimes_{\mathcal{O}_X}^\mathbf{L} \omega_{X/Y}^\bullet$
for $K \in D_\QCoh(\mathcal{O}_Y)$. Moreover, the trace map
$$
\text{Tr}_{f, \mathcal{O}_Y} : Rf_*\omega_{X/Y}^\bullet \to \mathcal{O}_Y
$$
of Section \ref{section-trace} induces the trace map for all $K$
in $D_\QCoh(\mathcal{O}_Y)$. More precisely the diagram
$$
\xymatrix{
Rf_*a(K) \ar[rrr]_{\text{Tr}_{f, K}} \ar@{=}[d] & & &
K \ar@{=}[d] \\
Rf_*(Lf^*K \otimes_{\mathcal{O}_X}^\mathbf{L} \omega_{X/Y}^\bullet)
\ar@{=}[r] &
K \otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*\omega_{X/Y}^\bullet
\ar[rr]^-{\text{id}_K \otimes \text{Tr}_{f, \mathcal{O}_Y}} & & K
}
$$
where the equality on the lower right is
Derived Categories of Schemes, Lemma \ref{perfect-lemma-cohomology-base-change}.
If $g : Y' \to Y$ is a
morphism of quasi-compact and quasi-separated schemes
and $X' = Y' \times_Y X$, then by
Lemma \ref{lemma-proper-flat-base-change} we have
$\omega_{X'/Y'}^\bullet = L(g')^*\omega_{X/Y}^\bullet$ where $g' : X' \to X$
is the projection and by Lemma \ref{lemma-trace-map-and-base-change}
the trace map
$$
\text{Tr}_{f', \mathcal{O}_{Y'}} :
Rf'_*\omega_{X'/Y'}^\bullet \to \mathcal{O}_{Y'}
$$
for $f' : X' \to Y'$ is the base change of $\text{Tr}_{f, \mathcal{O}_Y}$
via the base change isomorphism.
\end{remark}

\begin{remark}
\label{remark-relative-dualizing-complex-relative-cup-product}
Let $f : X \to Y$, $\omega^\bullet_{X/Y}$, and $\text{Tr}_{f, \mathcal{O}_Y}$
be as in Remark \ref{remark-relative-dualizing-complex}.
Let $K$ and $M$ be in $D_\QCoh(\mathcal{O}_X)$ with
$M$ pseudo-coherent (for example perfect). Suppose given a map
$K \otimes_{\mathcal{O}_X}^\mathbf{L} M \to \omega^\bullet_{X/Y}$
which corresponds to an isomorphism
$K \to R\SheafHom_{\mathcal{O}_X}(M, \omega^\bullet_{X/Y})$
via Cohomology, Equation (\ref{cohomology-equation-internal-hom}).
Then the relative cup product
(Cohomology, Remark \ref{cohomology-remark-cup-product})
$$
Rf_*K \otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*M
\to
Rf_*(K \otimes_{\mathcal{O}_X}^\mathbf{L} M)
\to
Rf_*\omega^\bullet_{X/Y}
\xrightarrow{\text{Tr}_{f, \mathcal{O}_Y}}
\mathcal{O}_Y
$$
determines an isomorphism
$Rf_*K \to R\SheafHom_{\mathcal{O}_Y}(Rf_*M, \mathcal{O}_Y)$.
Namely, since $\omega^\bullet_{X/Y} = a(\mathcal{O}_Y)$
the canonical map (\ref{equation-sheafy-trace})
$$
Rf_*R\SheafHom_{\mathcal{O}_X}(M, \omega^\bullet_{X/Y}) \to
R\SheafHom_{\mathcal{O}_Y}(Rf_*M, \mathcal{O}_Y)
$$
is an isomorphism by
Lemma \ref{lemma-iso-on-RSheafHom} and
Remark \ref{remark-iso-on-RSheafHom}
and the fact that $M$ and $Rf_*M$ are pseudo-coherent, see
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-flat-proper-pseudo-coherent-direct-image-general}.
To see that the relative cup product
induces this isomorphism use the commutativity of the diagram in
Cohomology, Remark \ref{cohomology-remark-relative-cup-and-composition}.
\end{remark}

\begin{lemma}
\label{lemma-properties-relative-dualizing}
Let $Y$ be a quasi-compact and quasi-separated scheme.
Let $f : X \to Y$ be a morphism of schemes which is
proper, flat, and of finite presentation with
relative dualizing complex $\omega_{X/Y}^\bullet$
(Remark \ref{remark-relative-dualizing-complex}).
Then
\begin{enumerate}
\item $\omega_{X/Y}^\bullet$ is a $Y$-perfect object of $D(\mathcal{O}_X)$,
\item $Rf_*\omega_{X/Y}^\bullet$ has vanishing cohomology sheaves
in positive degrees,
\item $\mathcal{O}_X \to
R\SheafHom_{\mathcal{O}_X}(\omega_{X/Y}^\bullet, \omega_{X/Y}^\bullet)$
is an isomorphism.
\end{enumerate}
\end{lemma}

\begin{proof}
In view of the fact that formation of $\omega_{X/Y}^\bullet$ commutes
with base change (see Remark \ref{remark-relative-dualizing-complex}),
we may and do assume that $Y$ is affine. For a perfect object $E$ of
$D(\mathcal{O}_X)$ we have
\begin{align*}
Rf_*(E \otimes_{\mathcal{O}_X}^\mathbf{L} \omega_{X/Y}^\bullet)
& =
Rf_*R\SheafHom_{\mathcal{O}_X}(E^\vee, \omega_{X/Y}^\bullet) \\
& =
R\SheafHom_{\mathcal{O}_Y}(Rf_*E^\vee, \mathcal{O}_Y) \\
& =
(Rf_*E^\vee)^\vee
\end{align*}
For the first equality, see
Cohomology, Lemma \ref{cohomology-lemma-dual-perfect-complex}.
For the second equality, see Lemma \ref{lemma-iso-on-RSheafHom},
Remark \ref{remark-iso-on-RSheafHom}, and 
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-flat-proper-perfect-direct-image-general}.
The third equality is the definition of the dual. In particular
these references also show that the outcome is a perfect object
of $D(\mathcal{O}_Y)$. We conclude that $\omega_{X/Y}^\bullet$
is $Y$-perfect by More on Morphisms, Lemma
\ref{more-morphisms-lemma-characterize-relatively-perfect}.
This proves (1).

\medskip\noindent
Let $M$ be an object of $D_\QCoh(\mathcal{O}_Y)$. Then
\begin{align*}
\Hom_Y(M, Rf_*\omega_{X/Y}^\bullet) & =
\Hom_X(Lf^*M, \omega_{X/Y}^\bullet) \\
& =
\Hom_Y(Rf_*Lf^*M, \mathcal{O}_Y) \\
& =
\Hom_Y(M \otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*\mathcal{O}_X, \mathcal{O}_Y)
\end{align*}
The first equality holds by Cohomology, Lemma
\ref{cohomology-lemma-adjoint}.
The second equality by construction of $a$.
The third equality by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-cohomology-base-change}.
Recall $Rf_*\mathcal{O}_X$ is perfect of tor amplitude in $[0, N]$
for some $N$, see
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-flat-proper-perfect-direct-image-general}.
Thus we can represent $Rf_*\mathcal{O}_X$ by a complex of
finite projective modules sitting in degrees $[0, N]$
(using More on Algebra, Lemma \ref{more-algebra-lemma-perfect}
and the fact that $Y$ is affine).
Hence if $M = \mathcal{O}_Y[-i]$ for some $i > 0$, then the last
group is zero. Since $Y$ is affine we conclude that
$H^i(Rf_*\omega_{X/Y}^\bullet) = 0$ for $i > 0$.
This proves (2).

\medskip\noindent
Let $E$ be a perfect object of $D_\QCoh(\mathcal{O}_X)$. Then
we have
\begin{align*}
\Hom_X(E, R\SheafHom_{\mathcal{O}_X}(\omega_{X/Y}^\bullet, \omega_{X/Y}^\bullet)
& =
\Hom_X(E \otimes_{\mathcal{O}_X}^\mathbf{L} \omega_{X/Y}^\bullet,
\omega_{X/Y}^\bullet) \\
& =
\Hom_Y(Rf_*(E \otimes_{\mathcal{O}_X}^\mathbf{L} \omega_{X/Y}^\bullet),
\mathcal{O}_Y) \\
& =
\Hom_Y(Rf_*(R\SheafHom_{\mathcal{O}_X}(E^\vee, \omega_{X/Y}^\bullet)),
\mathcal{O}_Y) \\
& =
\Hom_Y(R\SheafHom_{\mathcal{O}_Y}(Rf_*E^\vee, \mathcal{O}_Y),
\mathcal{O}_Y) \\
& =
R\Gamma(Y, Rf_*E^\vee) \\
& =
\Hom_X(E, \mathcal{O}_X)
\end{align*}
The first equality holds by Cohomology, Lemma
\ref{cohomology-lemma-internal-hom}.
The second equality is the definition of $\omega_{X/Y}^\bullet$.
The third equality comes from the construction of the dual perfect
complex $E^\vee$, see Cohomology, Lemma
\ref{cohomology-lemma-dual-perfect-complex}.
The fourth equality follows from the equality
$Rf_*R\SheafHom_{\mathcal{O}_X}(E^\vee, \omega_{X/Y}^\bullet) =
R\SheafHom_{\mathcal{O}_Y}(Rf_*E^\vee, \mathcal{O}_Y)$
shown in the first paragraph of the proof.
The fifth equality holds by double duality for perfect complexes
(Cohomology, Lemma
\ref{cohomology-lemma-dual-perfect-complex})
and the fact that $Rf_*E$ is perfect by
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-flat-proper-perfect-direct-image-general}.
The last equality is Leray for $f$.
This string of equalities essentially shows (3)
holds by the Yoneda lemma. Namely, the object
$R\SheafHom(\omega_{X/Y}^\bullet, \omega_{X/Y}^\bullet)$
is in $D_\QCoh(\mathcal{O}_X)$ by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-internal-hom}.
Taking $E = \mathcal{O}_X$ in the above we get a map
$\alpha : \mathcal{O}_X \to
R\SheafHom_{\mathcal{O}_X}(\omega_{X/Y}^\bullet, \omega_{X/Y}^\bullet)$
corresponding to
$\text{id}_{\mathcal{O}_X} \in \Hom_X(\mathcal{O}_X, \mathcal{O}_X)$.
Since all the isomorphisms above are functorial in $E$ we
see that the cone on $\alpha$ is an object $C$ of $D_\QCoh(\mathcal{O}_X)$
such that $\Hom(E, C) = 0$ for all perfect $E$.
Since the perfect objects generate
(Derived Categories of Schemes, Theorem
\ref{perfect-theorem-bondal-van-den-Bergh})
we conclude that $\alpha$ is an isomorphism.
\end{proof}

\begin{lemma}[Rigidity]
\label{lemma-van-den-bergh}
Let $Y$ be a quasi-compact and quasi-separated scheme.
Let $f : X \to Y$ be a proper, flat morphism of finite presentation
with relative dualizing complex $\omega_{X/Y}^\bullet$
(Remark \ref{remark-relative-dualizing-complex}).
There is a canonical isomorphism
\begin{equation}
\label{equation-pre-rigid}
\mathcal{O}_X =
c(L\text{pr}_1^*\omega_{X/Y}^\bullet) =
c(L\text{pr}_2^*\omega_{X/Y}^\bullet)
\end{equation}
and a canonical isomorphism
\begin{equation}
\label{equation-rigid}
\omega_{X/Y}^\bullet =
c\left(L\text{pr}_1^*\omega_{X/Y}^\bullet
\otimes_{\mathcal{O}_{X \times_Y X}}^\mathbf{L}
L\text{pr}_2^*\omega_{X/Y}^\bullet\right)
\end{equation}
where $c$ is the right adjoint of
Lemma \ref{lemma-twisted-inverse-image}
for the diagonal $\Delta : X \to X \times_Y X$.
\end{lemma}

\begin{proof}
Let $a$ be the right adjoint to $Rf_*$ as in
Lemma \ref{lemma-twisted-inverse-image}.
Consider the cartesian square
$$
\xymatrix{
X \times_Y X \ar[r]_q \ar[d]_p & X \ar[d]_f \\
X \ar[r]^f & Y
}
$$
Let $b$ be the right adjoint for $p$
as in Lemma \ref{lemma-twisted-inverse-image}. Then
\begin{align*}
\omega_{X/Y}^\bullet
& =
c(b(\omega_{X/Y}^\bullet)) \\
& =
c(Lp^*\omega_{X/Y}^\bullet
\otimes_{\mathcal{O}_{X \times_Y X}}^\mathbf{L} b(\mathcal{O}_X)) \\
& =
c(Lp^*\omega_{X/Y}^\bullet
\otimes_{\mathcal{O}_{X \times_Y X}}^\mathbf{L}
Lq^*a(\mathcal{O}_Y)) \\
& =
c(Lp^*\omega_{X/Y}^\bullet
\otimes_{\mathcal{O}_{X \times_Y X}}^\mathbf{L}
Lq^*\omega_{X/Y}^\bullet)
\end{align*}
as in (\ref{equation-rigid}). Explanation as follows:
\begin{enumerate}
\item The first equality holds as $\text{id} = c \circ b$ because
$\text{id}_X = p \circ \Delta$.
\item The second equality holds by
Lemma \ref{lemma-compare-with-pullback-flat-proper}.
\item The third holds by Lemma \ref{lemma-proper-flat-base-change}
and the fact that $\mathcal{O}_X = Lf^*\mathcal{O}_Y$.
\item The fourth holds because $\omega_{X/Y}^\bullet = a(\mathcal{O}_Y)$.
\end{enumerate}
Equation (\ref{equation-pre-rigid}) is proved in exactly the same way.
\end{proof}

\begin{remark}
\label{remark-van-den-bergh}
Lemma \ref{lemma-van-den-bergh} means our relative dualizing
complex is {\it rigid} in a sense analogous to the notion introduced
in \cite{vdB-rigid}. Namely, since the functor on the right of
(\ref{equation-rigid})
is ``quadratic'' in $\omega_{X/Y}^\bullet$ and the functor on the left
of (\ref{equation-rigid})
is ``linear'' this ``pins down'' the complex $\omega_{X/Y}^\bullet$
to some extent. There is an approach to duality theory using
``rigid'' (relative) dualizing complexes, see for example
\cite{Neeman-rigid}, \cite{Yekutieli-rigid}, and \cite{Yekutieli-Zhang}.
We will return to this in Section \ref{section-relative-dualizing-complexes}.
\end{remark}





\section{Right adjoint of pushforward for perfect proper morphisms}
\label{section-perfect-proper}

\noindent
The correct generality for this section would be to consider
perfect proper morphisms of quasi-compact and quasi-separated
schemes, see \cite{LN}.

\begin{lemma}
\label{lemma-proper-flat-noetherian}
Let $f : X \to Y$ be a perfect proper morphism of Noetherian schemes.
Let $a$ be the right adjoint for
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$ of
Lemma \ref{lemma-twisted-inverse-image}. Then $a$ commutes with direct sums.
\end{lemma}

\begin{proof}
Let $P$ be a perfect object of $D(\mathcal{O}_X)$. By
More on Morphisms, Lemma
\ref{more-morphisms-lemma-perfect-proper-perfect-direct-image}
the complex $Rf_*P$ is perfect on $Y$.
Let $K_i$ be a family of objects of $D_\QCoh(\mathcal{O}_Y)$.
Then
\begin{align*}
\Hom_{D(\mathcal{O}_X)}(P, a(\bigoplus K_i))
& =
\Hom_{D(\mathcal{O}_Y)}(Rf_*P, \bigoplus K_i) \\
& =
\bigoplus \Hom_{D(\mathcal{O}_Y)}(Rf_*P, K_i) \\
& =
\bigoplus \Hom_{D(\mathcal{O}_X)}(P, a(K_i))
\end{align*}
because a perfect object is compact (Derived Categories of Schemes,
Proposition \ref{perfect-proposition-compact-is-perfect}).
Since $D_\QCoh(\mathcal{O}_X)$ has a perfect generator
(Derived Categories of Schemes, Theorem
\ref{perfect-theorem-bondal-van-den-Bergh})
we conclude that the map $\bigoplus a(K_i) \to a(\bigoplus K_i)$
is an isomorphism, i.e., $a$ commutes with direct sums.
\end{proof}

\begin{lemma}
\label{lemma-proper-flat-noetherian-relative}
Let $f : X \to Y$ be a perfect proper morphism of Noetherian schemes.
Let $a$ be the right adjoint for
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$ of
Lemma \ref{lemma-twisted-inverse-image}. Then
\begin{enumerate}
\item for every closed $T \subset Y$ if $Q \in D_\QCoh(Y)$ is supported on $T$,
then $a(Q)$ is supported on $f^{-1}(T)$,
\item for every open $V \subset Y$ and any $K \in D_\QCoh(\mathcal{O}_Y)$
the map (\ref{equation-sheafy}) is an isomorphism, and
\end{enumerate}
\end{lemma}

\begin{proof}
This follows from Lemmas \ref{lemma-when-sheafy},
\ref{lemma-proper-noetherian}, and
\ref{lemma-proper-flat-noetherian}.
\end{proof}

\begin{lemma}
\label{lemma-compare-with-pullback-flat-proper-noetherian}
Let $f : X \to Y$ be a perfect proper morphism of Noetherian
schemes. The map (\ref{equation-compare-with-pullback}) is an isomorphism
for every object $K$ of $D_\QCoh(\mathcal{O}_Y)$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-proper-flat-noetherian} we know that $a$ commutes
with direct sums. Hence the collection of objects of
$D_\QCoh(\mathcal{O}_Y)$ for which (\ref{equation-compare-with-pullback})
is an isomorphism is a strictly full, saturated, triangulated
subcategory of $D_\QCoh(\mathcal{O}_Y)$ which is moreover
preserved under taking direct sums. Since $D_\QCoh(\mathcal{O}_Y)$
is a module category (Derived Categories of Schemes, Theorem
\ref{perfect-theorem-DQCoh-is-Ddga}) generated by a single
perfect object (Derived Categories of Schemes, Theorem
\ref{perfect-theorem-bondal-van-den-Bergh})
we can argue as in
More on Algebra, Remark \ref{more-algebra-remark-P-resolution}
to see that it suffices to prove (\ref{equation-compare-with-pullback})
is an isomorphism for a single perfect object.
However, the result holds for perfect objects, see
Lemma \ref{lemma-compare-with-pullback-perfect}.
\end{proof}

\begin{lemma}
\label{lemma-proper-perfect-base-change}
Let $f : X \to Y$ be a perfect proper morphism of Noetherian schemes.
Let $g : Y' \to Y$ be a morphism with $Y'$ Noetherian. If $X$ and
$Y'$ are tor independent over $Y$, then the base
change map (\ref{equation-base-change-map}) is an isomorphism
for all $K \in D_\QCoh(\mathcal{O}_Y)$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-proper-flat-noetherian-relative} formation of the
functors $a$ and $a'$ commutes with restriction to opens of $Y$ and $Y'$.
Hence we may assume $Y' \to Y$ is a morphism of affine schemes, see
Remark \ref{remark-check-over-affines}. In this
case the statement follows from Lemma \ref{lemma-more-base-change}.
\end{proof}



\section{Right adjoint of pushforward for effective Cartier divisors}
\label{section-dualizing-Cartier}

\noindent
Let $X$ be a scheme and let $i : D \to X$ be the inclusion of an
effective Cartier divisor. Denote $\mathcal{N} = i^*\mathcal{O}_X(D)$
the normal sheaf of $i$, see
Morphisms, Section \ref{morphisms-section-conormal-sheaf}
and
Divisors, Section \ref{divisors-section-effective-Cartier-divisors}.
Recall that $R\SheafHom(\mathcal{O}_D, -)$
denotes the right adjoint to $i_* : D(\mathcal{O}_D) \to D(\mathcal{O}_X)$
and has the property
$i_*R\SheafHom(\mathcal{O}_D, -) =
R\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_D, -)$,
see Section \ref{section-sections-with-exact-support}.

\begin{lemma}
\label{lemma-compute-for-effective-Cartier}
As above, let $X$ be a scheme and let $D \subset X$ be an
effective Cartier divisor. There is a canonical isomorphism
$R\SheafHom(\mathcal{O}_D, \mathcal{O}_X) = \mathcal{N}[-1]$
in $D(\mathcal{O}_D)$.
\end{lemma}

\begin{proof}
Equivalently, we are saying that $R\SheafHom(\mathcal{O}_D, \mathcal{O}_X)$
has a unique nonzero cohomology sheaf in degree $1$ and that this
sheaf is isomorphic to $\mathcal{N}$. Since $i_*$ is exact and fully
faithful, it suffices to prove that
$i_*R\SheafHom(\mathcal{O}_D, \mathcal{O}_X)$ is isomorphic
to $i_*\mathcal{N}[-1]$. We have
$i_*R\SheafHom(\mathcal{O}_D, \mathcal{O}_X) =
R\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_D, \mathcal{O}_X)$
by Lemma \ref{lemma-sheaf-with-exact-support-ext}. We have a resolution
$$
0 \to \mathcal{I} \to \mathcal{O}_X \to i_*\mathcal{O}_D \to 0
$$
where $\mathcal{I}$ is the ideal sheaf of $D$
which we can use to compute. Since
$R\SheafHom_{\mathcal{O}_X}(\mathcal{O}_X, \mathcal{O}_X) = \mathcal{O}_X$ and
$R\SheafHom_{\mathcal{O}_X}(\mathcal{I}, \mathcal{O}_X) = \mathcal{O}_X(D)$ by
a local computation, we see that
$$
R\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_D, \mathcal{O}_X) =
(\mathcal{O}_X \to \mathcal{O}_X(D))
$$
where on the right hand side we have $\mathcal{O}_X$ in degree $0$
and $\mathcal{O}_X(D)$ in degree $1$. The result follows from the
short exact sequence
$$
0 \to \mathcal{O}_X \to \mathcal{O}_X(D) \to i_*\mathcal{N} \to 0
$$
coming from the fact that $D$ is the zero scheme of the canonical section
of $\mathcal{O}_X(D)$ and from the fact that
$\mathcal{N} = i^*\mathcal{O}_X(D)$.
\end{proof}

\noindent
For every object $K$ of $D(\mathcal{O}_X)$ there is a canonical map
\begin{equation}
\label{equation-map-effective-Cartier}
Li^*K
\otimes_{\mathcal{O}_D}^\mathbf{L}
R\SheafHom(\mathcal{O}_D, \mathcal{O}_X)
\longrightarrow
R\SheafHom(\mathcal{O}_D, K)
\end{equation}
in $D(\mathcal{O}_D)$ functorial in $K$ and
compatible with distinguished triangles.
Namely, this map is adjoint to a map
$$
i_*(Li^*K \otimes^\mathbf{L}_{\mathcal{O}_D}
R\SheafHom(\mathcal{O}_D, \mathcal{O}_X)) =
K \otimes^\mathbf{L}_{\mathcal{O}_X}
R\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_D, \mathcal{O}_X)
\longrightarrow K
$$
where the equality is
Cohomology, Lemma \ref{cohomology-lemma-projection-formula-closed-immersion}
and the arrow comes from the canonical map
$R\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_D, \mathcal{O}_X) \to \mathcal{O}_X$
induced by $\mathcal{O}_X \to i_*\mathcal{O}_D$.

\medskip\noindent
If $K \in D_\QCoh(\mathcal{O}_X)$, then
(\ref{equation-map-effective-Cartier}) is equal to
(\ref{equation-compare-with-pullback}) via the identification
$a(K) = R\SheafHom(\mathcal{O}_D, K)$ of
Lemma \ref{lemma-twisted-inverse-image-closed}.
If $K \in D_\QCoh(\mathcal{O}_X)$ and $X$ is Noetherian, then
the following lemma is a special case of
Lemma \ref{lemma-compare-with-pullback-flat-proper-noetherian}.

\begin{lemma}
\label{lemma-sheaf-with-exact-support-effective-Cartier}
As above, let $X$ be a scheme and let $D \subset X$ be an
effective Cartier divisor. Then (\ref{equation-map-effective-Cartier})
combined with Lemma \ref{lemma-compute-for-effective-Cartier}
defines an isomorphism
$$
Li^*K \otimes_{\mathcal{O}_D}^\mathbf{L} \mathcal{N}[-1]
\longrightarrow
R\SheafHom(\mathcal{O}_D, K)
$$
functorial in $K$ in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Since $i_*$ is exact and fully faithful on modules, to prove the map is an
isomorphism, it suffices to show that it is an isomorphism after applying
$i_*$. We will use the short exact sequences
$0 \to \mathcal{I} \to \mathcal{O}_X \to i_*\mathcal{O}_D \to 0$
and
$0 \to \mathcal{O}_X \to \mathcal{O}_X(D) \to i_*\mathcal{N} \to 0$
used in the proof of Lemma \ref{lemma-compute-for-effective-Cartier}
without further mention. By
Cohomology, Lemma \ref{cohomology-lemma-projection-formula-closed-immersion}
which was used to define the map (\ref{equation-map-effective-Cartier})
the left hand side becomes
$$
K \otimes_{\mathcal{O}_X}^\mathbf{L} i_*\mathcal{N}[-1] =
K \otimes_{\mathcal{O}_X}^\mathbf{L} (\mathcal{O}_X \to \mathcal{O}_X(D))
$$
The right hand side becomes
\begin{align*}
R\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_D, K) & =
R\SheafHom_{\mathcal{O}_X}((\mathcal{I} \to \mathcal{O}_X), K) \\
& =
R\SheafHom_{\mathcal{O}_X}((\mathcal{I} \to \mathcal{O}_X), \mathcal{O}_X)
\otimes_{\mathcal{O}_X}^\mathbf{L} K
\end{align*}
the final equality by
Cohomology, Lemma \ref{cohomology-lemma-dual-perfect-complex}.
Since the map comes from the isomorphism
$$
R\SheafHom_{\mathcal{O}_X}((\mathcal{I} \to \mathcal{O}_X), \mathcal{O}_X)
= (\mathcal{O}_X \to \mathcal{O}_X(D))
$$
the lemma is clear.
\end{proof}





\section{Right adjoint of pushforward in examples}
\label{section-examples}

\noindent
In this section we compute the right adjoint to pushforward in
some examples. The isomorphisms are canonical but only in the weakest
possible sense, i.e., we do not prove or claim that these isomorphisms are
compatible with various operations such as base change and compositions
of morphisms. There is a huge literature on these types of issues; the reader
can start with the material in \cite{RD}, \cite{Conrad-GD}
(these citations use a different starting point for duality but address the
issue of constructing canonical representatives for relative dualizing
complexes) and then continue looking at works by
Joseph Lipman and collaborators.

\begin{lemma}
\label{lemma-upper-shriek-P1}
Let $Y$ be a quasi-compact and quasi-separated scheme.
Let $\mathcal{E}$ be a finite locally
free $\mathcal{O}_Y$-module of rank $n + 1$ with determinant
$\mathcal{L} = \wedge^{n + 1}(\mathcal{E})$.
Let $f : X = \mathbf{P}(\mathcal{E}) \to Y$ be the projection.
Let $a$ be the right adjoint for
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$ of
Lemma \ref{lemma-twisted-inverse-image}.
Then there is an isomorphism
$$
c : f^*\mathcal{L}(-n - 1)[n] \longrightarrow a(\mathcal{O}_Y)
$$
In particular, if $\mathcal{E} = \mathcal{O}_Y^{\oplus n + 1}$, then
$X = \mathbf{P}^n_Y$ and we obtain
$a(\mathcal{O}_Y) = \mathcal{O}_X(-n - 1)[n]$.
\end{lemma}

\begin{proof}
In (the proof of) Cohomology of Schemes, Lemma
\ref{coherent-lemma-cohomology-projective-bundle}
we constructed a canonical isomorphism
$$
R^nf_*(f^*\mathcal{L}(-n - 1)) \longrightarrow \mathcal{O}_Y
$$
Moreover, $Rf_*(f^*\mathcal{L}(-n - 1))[n] = R^nf_*(f^*\mathcal{L}(-n - 1))$,
i.e., the other higher direct images are zero. Thus we find an isomorphism
$$
Rf_*(f^*\mathcal{L}(-n - 1)[n]) \longrightarrow \mathcal{O}_Y
$$
This isomorphism determines $c$ as in the statement of the lemma
because $a$ is the right adjoint of $Rf_*$.
By Lemma \ref{lemma-proper-noetherian} construction of the $a$
is local on the base. In particular, to check that
$c$ is an isomorphism, we may work locally on $Y$.
In other words, we may assume $Y$ is affine and
$\mathcal{E} = \mathcal{O}_Y^{\oplus n + 1}$.
In this case the sheaves $\mathcal{O}_X, \mathcal{O}_X(-1), \ldots,
\mathcal{O}_X(-n)$ generate $D_\QCoh(X)$, see
Derived Categories of Schemes, Lemma \ref{perfect-lemma-generator-P1}.
Hence it suffices to show that
$c : \mathcal{O}_X(-n - 1)[n] \to a(\mathcal{O}_Y)$
is transformed into an isomorphism under the functors
$$
F_{i, p}(-) = \Hom_{D(\mathcal{O}_X)}(\mathcal{O}_X(i), (-)[p])
$$
for $i \in \{-n, \ldots, 0\}$ and $p \in \mathbf{Z}$.
For $F_{0, p}$ this holds by construction of the arrow $c$!
For $i \in \{-n, \ldots, -1\}$ we have
$$
\Hom_{D(\mathcal{O}_X)}(\mathcal{O}_X(i), \mathcal{O}_X(-n - 1)[n + p]) =
H^p(X, \mathcal{O}_X(-n - 1 - i)) = 0
$$
by the computation of cohomology of projective space
(Cohomology of Schemes, Lemma
\ref{coherent-lemma-cohomology-projective-space-over-ring})
and we have
$$
\Hom_{D(\mathcal{O}_X)}(\mathcal{O}_X(i), a(\mathcal{O}_Y)[p]) =
\Hom_{D(\mathcal{O}_Y)}(Rf_*\mathcal{O}_X(i), \mathcal{O}_Y[p]) = 0
$$
because $Rf_*\mathcal{O}_X(i) = 0$ by the same lemma.
Hence the source and the target of $F_{i, p}(c)$ vanish
and $F_{i, p}(c)$ is necessarily an isomorphism.
This finishes the proof.
\end{proof}

\begin{example}
\label{example-base-change-wrong}
The base change map (\ref{equation-base-change-map}) is not an
isomorphism if $f$ is perfect proper and $g$ is perfect.
Let $k$ be a field. Let $Y = \mathbf{A}^2_k$ and let $f : X \to Y$
be the blowup of $Y$ in the origin. Denote $E \subset X$ the
exceptional divisor. Then we can factor $f$ as
$$
X \xrightarrow{i} \mathbf{P}^1_Y \xrightarrow{p} Y
$$
This gives a factorization $a = c \circ b$ where
$a$, $b$, and $c$ are the right adjoints of
Lemma \ref{lemma-twisted-inverse-image}
of $Rf_*$, $Rp_*$, and $Ri_*$. Denote $\mathcal{O}(n)$ the
Serre twist of the structure sheaf on $\mathbf{P}^1_Y$ and
denote $\mathcal{O}_X(n)$ its restriction to $X$.
Note that $X \subset \mathbf{P}^1_Y$ is cut out by
a degree one equation, hence $\mathcal{O}(X) = \mathcal{O}(1)$.
By Lemma \ref{lemma-upper-shriek-P1} we have
$b(\mathcal{O}_Y) = \mathcal{O}(-2)[1]$.
By Lemma \ref{lemma-twisted-inverse-image-closed}
we have
$$
a(\mathcal{O}_Y) = c(b(\mathcal{O}_Y)) =
c(\mathcal{O}(-2)[1]) =
R\SheafHom(\mathcal{O}_X, \mathcal{O}(-2)[1]) =
\mathcal{O}_X(-1)
$$
Last equality by Lemma \ref{lemma-sheaf-with-exact-support-effective-Cartier}.
Let $Y' = \Spec(k)$ be the origin in $Y$. The restriction of
$a(\mathcal{O}_Y)$ to $X' = E = \mathbf{P}^1_k$
is an invertible sheaf of degree $-1$ placed in cohomological
degree $0$. But on the other hand,
$a'(\mathcal{O}_{\Spec(k)}) = \mathcal{O}_E(-2)[1]$
which is an invertible sheaf of degree $-2$ placed in
cohomological degree $-1$, so different. In this example
the hypothesis of Tor independence in Lemma \ref{lemma-more-base-change}
is violated.
\end{example}

\begin{lemma}
\label{lemma-ext}
Let $Y$ be a ringed space. Let $\mathcal{I} \subset \mathcal{O}_Y$
be a sheaf of ideals. Set $\mathcal{O}_X = \mathcal{O}_Y/\mathcal{I}$ and
$\mathcal{N} =
\SheafHom_{\mathcal{O}_Y}(\mathcal{I}/\mathcal{I}^2, \mathcal{O}_X)$.
There is a canonical isomorphism
$c : \mathcal{N} \to
\SheafExt^1_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
$.
\end{lemma}

\begin{proof}
Consider the canonical short exact sequence
\begin{equation}
\label{equation-second-order-thickening}
0 \to \mathcal{I}/\mathcal{I}^2 \to \mathcal{O}_Y/\mathcal{I}^2 \to
\mathcal{O}_X \to 0
\end{equation}
Let $U \subset X$ be open and let $s \in \mathcal{N}(U)$. Then we can
pushout (\ref{equation-second-order-thickening}) via $s$ to
get an extension $E_s$ of $\mathcal{O}_X|_U$ by $\mathcal{O}_X|_U$.
This in turn defines a section $c(s)$ of
$\SheafExt^1_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)$
over $U$.
See Cohomology, Lemma \ref{cohomology-lemma-section-RHom-over-U}
and Derived Categories, Lemma \ref{derived-lemma-ext-1}.
Conversely, given an extension
$$
0 \to \mathcal{O}_X|_U \to \mathcal{E} \to \mathcal{O}_X|_U \to 0
$$
of $\mathcal{O}_U$-modules, we can find an open covering
$U = \bigcup U_i$ and sections $e_i \in \mathcal{E}(U_i)$
mapping to $1 \in \mathcal{O}_X(U_i)$. Then $e_i$ defines a map
$\mathcal{O}_Y|_{U_i} \to \mathcal{E}|_{U_i}$ whose kernel
contains $\mathcal{I}^2$. In this way we see that
$\mathcal{E}|_{U_i}$ comes from a pushout as above.
This shows that $c$ is surjective. We omit the proof
of injectivity.
\end{proof}

\begin{lemma}
\label{lemma-regular-ideal-ext}
Let $Y$ be a ringed space. Let $\mathcal{I} \subset \mathcal{O}_Y$
be a sheaf of ideals. Set $\mathcal{O}_X = \mathcal{O}_Y/\mathcal{I}$.
If $\mathcal{I}$ is Koszul-regular
(Divisors, Definition \ref{divisors-definition-regular-ideal-sheaf})
then composition on $R\SheafHom_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)$
defines isomorphisms
$$
\wedge^i(\SheafExt^1_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X))
\longrightarrow
\SheafExt^i_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
$$
for all $i$.
\end{lemma}

\begin{proof}
By composition we mean the map
$$
R\SheafHom_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
\otimes_{\mathcal{O}_Y}^\mathbf{L}
R\SheafHom_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
\longrightarrow
R\SheafHom_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
$$
of Cohomology, Lemma \ref{cohomology-lemma-internal-hom-composition}.
This induces multiplication maps
$$
\SheafExt^a_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
\otimes_{\mathcal{O}_Y}
\SheafExt^b_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
\longrightarrow
\SheafExt^{a + b}_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
$$
Please compare with
More on Algebra, Equation (\ref{more-algebra-equation-simple-tor-product}).
The statement of the lemma means that the induced map
$$
\SheafExt^1_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
\otimes \ldots \otimes
\SheafExt^1_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
\longrightarrow
\SheafExt^i_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
$$
factors through the wedge product and then induces an isomorphism.
To see this is true we may work locally on $Y$. Hence we may assume
that we have global sections $f_1, \ldots, f_r$ of $\mathcal{O}_Y$
which generate $\mathcal{I}$ and which form a Koszul regular sequence.
Denote
$$
\mathcal{A} = \mathcal{O}_Y\langle \xi_1, \ldots, \xi_r\rangle
$$
the sheaf of strictly commutative differential graded $\mathcal{O}_Y$-algebras
which is a (divided power) polynomial algebra on
$\xi_1, \ldots, \xi_r$ in degree $-1$ over $\mathcal{O}_Y$
with differential $\text{d}$ given by the rule $\text{d}\xi_i = f_i$.
Let us denote $\mathcal{A}^\bullet$ the underlying
complex of $\mathcal{O}_Y$-modules which is the Koszul complex
mentioned above. Thus the canonical map
$\mathcal{A}^\bullet \to \mathcal{O}_X$
is a quasi-isomorphism. We obtain quasi-isomorphisms
$$
R\SheafHom_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X) \to
\SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{A}^\bullet) \to
\SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{O}_X)
$$
by Cohomology, Lemma \ref{cohomology-lemma-Rhom-strictly-perfect}.
The differentials of the latter complex are zero, and hence
$$
\SheafExt^i_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
\cong \SheafHom_{\mathcal{O}_Y}(\mathcal{A}^{-i}, \mathcal{O}_X)
$$
For $j \in \{1, \ldots, r\}$ let $\delta_j : \mathcal{A} \to \mathcal{A}$
be the derivation of degree $1$ with $\delta_j(\xi_i) = \delta_{ij}$
(Kronecker delta). A computation shows that
$\delta_j \circ \text{d} = - \text{d} \circ \delta_j$ which shows that
we get a morphism of complexes
$$
\delta_j : \mathcal{A}^\bullet \to \mathcal{A}^\bullet[1].
$$
Whence $\delta_j$ defines a section of the corresponding
$\SheafExt$-sheaf.
Another computation shows that $\delta_1, \ldots, \delta_r$
map to a basis for $\SheafHom_{\mathcal{O}_Y}(\mathcal{A}^{-1}, \mathcal{O}_X)$
over $\mathcal{O}_X$.
Since it is clear that $\delta_j \circ \delta_j = 0$
and $\delta_j \circ \delta_{j'} = - \delta_{j'} \circ \delta_j$
as endomorphisms of $\mathcal{A}$ and hence in the
$\SheafExt$-sheaves
we obtain the statement that our map above factors through
the exterior power. To see we get the desired isomorphism
the reader checks that the elements
$$
\delta_{j_1} \circ \ldots \circ \delta_{j_i}
$$
for $j_1 < \ldots < j_i$ map to a basis of the sheaf
$\SheafHom_{\mathcal{O}_Y}(\mathcal{A}^{-i}, \mathcal{O}_X)$
over $\mathcal{O}_X$.
\end{proof}

\begin{lemma}
\label{lemma-regular-immersion-ext}
Let $Y$ be a ringed space. Let $\mathcal{I} \subset \mathcal{O}_Y$
be a sheaf of ideals. Set $\mathcal{O}_X = \mathcal{O}_Y/\mathcal{I}$ and
$\mathcal{N} =
\SheafHom_{\mathcal{O}_Y}(\mathcal{I}/\mathcal{I}^2, \mathcal{O}_X)$.
If $\mathcal{I}$ is Koszul-regular
(Divisors, Definition \ref{divisors-definition-regular-ideal-sheaf}) then
$$
R\SheafHom_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_Y) =
\wedge^r \mathcal{N}[-r]
$$
where $r : Y \to \{1, 2, 3, \ldots \}$ sends $y$ to
the minimal number of generators of $\mathcal{I}$ needed in a neighbourhood
of $y$.
\end{lemma}

\begin{proof}
We can use Lemmas \ref{lemma-ext} and \ref{lemma-regular-ideal-ext}
to see that we have isomorphisms
$\wedge^i\mathcal{N} \to
\SheafExt^i_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)$
for $i \geq 0$. Thus it suffices to show that the map
$\mathcal{O}_Y \to \mathcal{O}_X$ induces an isomorphism
$$
\SheafExt^r_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_Y)
\longrightarrow
\SheafExt^r_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)
$$
and that
$\SheafExt^i_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_Y)$
is zero for $i \not = r$. These statements are local on $Y$. Thus
we may assume that we have global sections $f_1, \ldots, f_r$ of
$\mathcal{O}_Y$ which generate $\mathcal{I}$ and which form a
Koszul regular sequence. Let $\mathcal{A}^\bullet$
be the Koszul complex on $f_1, \ldots, f_r$ as introduced in the proof of
Lemma \ref{lemma-regular-ideal-ext}. Then
$$
R\SheafHom_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_Y) =
\SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{O}_Y)
$$
by Cohomology, Lemma \ref{cohomology-lemma-Rhom-strictly-perfect}.
Denote $1 : \mathcal{A}^\bullet \to \mathcal{O}_Y$ the map of differential
graded $\mathcal{O}_Y$-algebras given by the identity map of
$\mathcal{A}^0 = \mathcal{O}_Y \to \mathcal{O}_Y$ in degree $0$.
With $\delta_j$ as in the proof of Lemma \ref{lemma-regular-ideal-ext}
we get an isomorphism of graded $\mathcal{O}_Y$-modules
$$
\mathcal{O}_Y\langle \delta_1, \ldots, \delta_r\rangle
\longrightarrow
\SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{O}_Y)
$$
by mapping $\delta_{j_1} \ldots \delta_{j_i}$ to
$1 \circ \delta_{j_1} \circ \ldots \circ \delta_{j_i}$ in degree $i$.
Via this isomorphism the differential on the right hand side
induces a differential $\text{d}$ on the left hand side.
By our sign rules we have $\text{d}(1) = - \sum f_j \delta_j$.
Since $\delta_j : \mathcal{A}^\bullet \to \mathcal{A}^\bullet[1]$
is a morphism of complexes, it follows that
$$
\text{d}(\delta_{j_1} \ldots \delta_{j_i}) =
(- \sum f_j \delta_j )\delta_{j_1} \ldots \delta_{j_i}
$$
Observe that we have $\text{d} = \sum f_j \delta_j$ on the differential
graded algebra $\mathcal{A}$. Therefore the map defined by the rule
$$
1 \circ \delta_{j_1} \ldots \delta_{j_i} \longmapsto
(\delta_{j_1} \circ \ldots \circ \delta_{j_i})(\xi_1 \ldots \xi_r)
$$
will define an isomorphism of complexes
$$
\SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{O}_Y)
\longrightarrow \mathcal{A}^\bullet[-r]
$$
if $r$ is odd and commuting with differentials up to sign if $r$ is even.
In any case these complexes have isomorphic cohomology, which shows the
desired vanishing. The isomorphism on cohomology in degree $r$
under the map
$$
\SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{O}_Y)
\longrightarrow
\SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{O}_X)
$$
also follows in a straightforward manner from this.
(We observe that our choice of conventions regarding
Koszul complexes does intervene in the definition
of the isomorphism
$R\SheafHom_{\mathcal{O}_X}(\mathcal{O}_X, \mathcal{O}_Y) =
\wedge^r \mathcal{N}[-r]$.)
\end{proof}

\begin{lemma}
\label{lemma-regular-immersion}
Let $Y$ be a quasi-compact and quasi-separated scheme.
Let $i : X \to Y$ be a Koszul-regular closed immersion.
Let $a$ be the right adjoint of
$Ri_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$ of
Lemma \ref{lemma-twisted-inverse-image}. Then there is an isomorphism
$$
\wedge^r\mathcal{N}[-r] \longrightarrow a(\mathcal{O}_Y)
$$
where
$\mathcal{N} = \SheafHom_{\mathcal{O}_X}(\mathcal{C}_{X/Y}, \mathcal{O}_X)$
is the normal sheaf of $i$
(Morphisms, Section \ref{morphisms-section-conormal-sheaf})
and $r$ is its rank viewed as a locally constant
function on $X$.
\end{lemma}

\begin{proof}
Recall, from Lemmas \ref{lemma-twisted-inverse-image-closed}
and \ref{lemma-sheaf-with-exact-support-ext},
that $a(\mathcal{O}_Y)$ is an object of $D_\QCoh(\mathcal{O}_X)$ whose
pushforward to $Y$ is
$R\SheafHom_{\mathcal{O}_Y}(i_*\mathcal{O}_X, \mathcal{O}_Y)$.
Thus the result follows from Lemma \ref{lemma-regular-immersion-ext}.
\end{proof}

\begin{lemma}
\label{lemma-smooth-proper}
Let $S$ be a Noetherian scheme.
Let $f : X \to S$ be a smooth proper morphism of relative dimension $d$.
Let $a$ be the right adjoint of
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_S)$ as in
Lemma \ref{lemma-twisted-inverse-image}. Then there is an isomorphism
$$
\wedge^d \Omega_{X/S}[d] \longrightarrow a(\mathcal{O}_S)
$$
in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Set $\omega_{X/S}^\bullet = a(\mathcal{O}_S)$ as in
Remark \ref{remark-relative-dualizing-complex}.
Let $c$ be the right adjoint of Lemma \ref{lemma-twisted-inverse-image} for
$\Delta : X \to X \times_S X$. Because $\Delta$
is the diagonal of a smooth morphism it is a
Koszul-regular immersion, see Divisors, Lemma
\ref{divisors-lemma-immersion-smooth-into-smooth-regular-immersion}.
In particular, $\Delta$ is a perfect proper morphism
(More on Morphisms, Lemma \ref{more-morphisms-lemma-regular-immersion-perfect})
and we obtain
\begin{align*}
\mathcal{O}_X
& =
c(L\text{pr}_1^*\omega_{X/S}^\bullet) \\
& =
L\Delta^*(L\text{pr}_1^*\omega_{X/S}^\bullet)
\otimes_{\mathcal{O}_X}^\mathbf{L}
c(\mathcal{O}_{X \times_S X}) \\
& =
\omega_{X/S}^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L}
c(\mathcal{O}_{X \times_S X}) \\
& =
\omega_{X/S}^\bullet
\otimes_{\mathcal{O}_X}^\mathbf{L}
\wedge^d(\mathcal{N}_\Delta)[-d]
\end{align*}
The first equality is (\ref{equation-pre-rigid}) because
$\omega_{X/S}^\bullet = a(\mathcal{O}_S)$. The second equality by
Lemma \ref{lemma-compare-with-pullback-flat-proper-noetherian}.
The third equality because $\text{pr}_1 \circ \Delta = \text{id}_X$.
The fourth equality by Lemma \ref{lemma-regular-immersion}.
Observe that $\wedge^d(\mathcal{N}_\Delta)$ is an invertible
$\mathcal{O}_X$-module. Hence $\wedge^d(\mathcal{N}_\Delta)[-d]$
is an invertible object of $D(\mathcal{O}_X)$ and we conclude that
$a(\mathcal{O}_S) = \omega_{X/S}^\bullet = \wedge^d(\mathcal{C}_\Delta)[d]$.
Since the conormal sheaf $\mathcal{C}_\Delta$ of $\Delta$ is
$\Omega_{X/S}$ by
Morphisms, Lemma \ref{morphisms-lemma-differentials-diagonal}
the proof is complete.
\end{proof}







\section{Upper shriek functors}
\label{section-upper-shriek}

\noindent
In this section, we construct the functors $f^!$ for morphisms
between schemes which are of finite type and separated
over a fixed Noetherian base using compactifications.
As is customary in coherent duality, there are a number of diagrams
that have to be shown to be commutative. We suggest the reader,
after reading the construction, skips the verification of the
lemmas and continues to the next section where we discuss
properties of the upper shriek functors.

\begin{situation}
\label{situation-shriek}
Here $S$ is a Noetherian scheme and $\textit{FTS}_S$ is the category whose
\begin{enumerate}
\item objects are schemes $X$ over $S$ such that the structure
morphism $X \to S$ is both separated and of finite type, and
\item morphisms $f : X \to Y$ between objects are morphisms
of schemes over $S$.
\end{enumerate}
\end{situation}

\noindent
In Situation \ref{situation-shriek} given a morphism $f : X \to Y$
in $\textit{FTS}_S$, we will define an exact functor
$$
f^! : D_\QCoh^+(\mathcal{O}_Y) \to D_\QCoh^+(\mathcal{O}_X)
$$
of triangulated categories. Namely, we choose a compactification
$X \to \overline{X}$ over $Y$ which is possible by
More on Flatness, Theorem \ref{flat-theorem-nagata} and
Lemma \ref{flat-lemma-compactifyable}.
Denote $\overline{f} : \overline{X} \to Y$
the structure morphism. Let
$\overline{a} : D_\QCoh(\mathcal{O}_Y) \to D_\QCoh(\mathcal{O}_{\overline{X}})$
be the right adjoint of $R\overline{f}_*$
constructed in Lemma \ref{lemma-twisted-inverse-image}. Then we set
$$
f^!K  = \overline{a}(K)|_X
$$
for $K \in D_\QCoh^+(\mathcal{O}_Y)$. The result is an object of
$D_\QCoh^+(\mathcal{O}_X)$ by
Lemma \ref{lemma-twisted-inverse-image-bounded-below}.

\begin{lemma}
\label{lemma-shriek-well-defined}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism
of $\textit{FTS}_S$. The functor $f^!$ is, up to canonical isomorphism,
independent of the choice of the compactification.
\end{lemma}

\begin{proof}
The category of compactifications of $X$ over $Y$ is defined
in More on Flatness, Section \ref{flat-section-compactify}.
By More on Flatness, Theorem \ref{flat-theorem-nagata} and
Lemma \ref{flat-lemma-compactifyable} it is nonempty.
To every choice of a compactification
$$
j : X \to \overline{X},\quad \overline{f} : \overline{X} \to Y
$$
the construction above associates the functor $j^* \circ \overline{a} :
D_\QCoh^+(\mathcal{O}_Y) \to D_\QCoh^+(\mathcal{O}_X)$
where $\overline{a}$ is the right adjoint of $R\overline{f}_*$
constructed in Lemma \ref{lemma-twisted-inverse-image}.

\medskip\noindent
Suppose given a morphism $g : \overline{X}_1 \to \overline{X}_2$
between compactifications $j_i : X \to \overline{X}_i$ over $Y$
such that $g^{-1}(j_2(X)) = j_1(X)$\footnote{This may fail
with our definition of compactification. See
More on Flatness, Section \ref{flat-section-compactify}.}.
Let $\overline{c}$ be the right adjoint of
Lemma \ref{lemma-twisted-inverse-image} for $g$.
Then $\overline{c} \circ \overline{a}_2 = \overline{a}_1$
because these functors are adjoint to
$R\overline{f}_{2, *} \circ Rg_* = R(\overline{f}_2 \circ g)_*$.
By (\ref{equation-sheafy}) we have a canonical transformation
$$
j_1^* \circ \overline{c} \longrightarrow j_2^*
$$
of functors
$D^+_\QCoh(\mathcal{O}_{\overline{X}_2}) \to D^+_\QCoh(\mathcal{O}_X)$
which is an isomorphism by Lemma \ref{lemma-proper-noetherian}.
The composition
$$
j_1^* \circ \overline{a}_1 \longrightarrow
j_1^* \circ \overline{c} \circ \overline{a}_2 \longrightarrow
j_2^* \circ \overline{a}_2
$$
is an isomorphism of functors which we will denote by $\alpha_g$.

\medskip\noindent
Consider two compactifications $j_i : X \to \overline{X}_i$, $i = 1, 2$
of $X$ over $Y$. By More on Flatness, Lemma
\ref{flat-lemma-compactifications-cofiltered} part (b)
we can find a compactification $j : X \to \overline{X}$
with dense image and morphisms
$g_i : \overline{X} \to \overline{X}_i$ of compactifications.
By More on Flatness, Lemma
\ref{flat-lemma-compactifications-cofiltered} part (c)
we have $g_i^{-1}(j_i(X)) = j(X)$. Hence we get isomorpisms
$$
\alpha_{g_i} :
j^* \circ \overline{a}
\longrightarrow
j_i^* \circ \overline{a}_i
$$
by the previous paragraph. We obtain an isomorphism
$$
\alpha_{g_2} \circ \alpha_{g_1}^{-1} :
j_1^* \circ \overline{a}_1 \to j_2^* \circ \overline{a}_2
$$
To finish the proof we have to show that these isomorphisms are well defined.
We claim it suffices to show the composition of isomorphisms constructed
in the previous paragraph is another (for a precise statement see the next
paragraph). We suggest the reader check this is true on a napkin, but we
will also completely spell it out in the rest of this paragraph.
Namely, consider a second choice of a compactification
$j' : X \to \overline{X}'$ with dense image
and morphisms of compactifications $g'_i : \overline{X}' \to \overline{X}_i$.
By More on Flatness, Lemma \ref{flat-lemma-compactifications-cofiltered}
we can find a compactification $j'' : X \to \overline{X}''$
with dense image and morphisms of compactifications
$h : \overline{X}'' \to \overline{X}$ and
$h' : \overline{X}'' \to \overline{X}'$. We may even assume
$g_1 \circ h = g'_1 \circ h'$ and $g_2 \circ h = g'_2 \circ h'$.
The result of the next paragraph gives
$$
\alpha_{g_i} \circ \alpha_h = \alpha_{g_i \circ h} =
\alpha_{g'_i \circ h'} = \alpha_{g'_i} \circ \alpha_{h'}
$$
for $i = 1, 2$. Since these are all isomorphisms of functors
we conclude that $\alpha_{g_2} \circ \alpha_{g_1}^{-1} =
\alpha_{g'_2} \circ \alpha_{g'_1}^{-1}$ as desired.

\medskip\noindent
Suppose given compactifications $j_i : X \to \overline{X}_i$
for $i = 1, 2, 3$.  Suppose given morphisms
$g : \overline{X}_1 \to \overline{X}_2$ and
$h : \overline{X}_2 \to \overline{X}_3$ of compactifications
such that $g^{-1}(j_2(X)) = j_1(X)$ and $h^{-1}(j_2(X)) = j_3(X)$.
Let $\overline{a}_i$ be as above. The claim above means that
$$
\alpha_g \circ \alpha_h = \alpha_{g \circ h} :
j_1^* \circ \overline{a}_1 \to j_3^* \circ \overline{a}_3
$$
Let $\overline{c}$, resp.\ $\overline{d}$ be the right adjoint of
Lemma \ref{lemma-twisted-inverse-image} for $g$, resp.\ $h$.
Then $\overline{c} \circ \overline{a}_2 = \overline{a}_1$ and
$\overline{d} \circ \overline{a}_3 = \overline{a}_2$
and there are canonical transformations
$$
j_1^* \circ \overline{c} \longrightarrow j_2^*
\quad\text{and}\quad
j_2^* \circ \overline{d} \longrightarrow j_3^*
$$
of functors
$D^+_\QCoh(\mathcal{O}_{\overline{X}_2}) \to D^+_\QCoh(\mathcal{O}_X)$
and
$D^+_\QCoh(\mathcal{O}_{\overline{X}_3}) \to D^+_\QCoh(\mathcal{O}_X)$
for the same reasons as above. Denote $\overline{e}$ the
right adjoint of Lemma \ref{lemma-twisted-inverse-image}
for $h \circ g$. There is a canonical transformation
$$
j_1^* \circ \overline{e} \longrightarrow j_3^*
$$
of functors
$D^+_\QCoh(\mathcal{O}_{\overline{X}_3}) \to D^+_\QCoh(\mathcal{O}_X)$
given by (\ref{equation-sheafy}). Spelling things out we have to
show that the composition
$$
\alpha_h \circ \alpha_g :
j_1^* \circ \overline{a}_1 \to
j_1^* \circ \overline{c} \circ \overline{a}_2 \to
j_2^* \circ \overline{a}_2 \to
j_2^* \circ \overline{d} \circ \overline{a}_3 \to
j_3^* \circ \overline{a}_3
$$
is the same as the composition
$$
\alpha_{h \circ g} :
j_1^* \circ \overline{a}_1 \to
j_1^* \circ \overline{e} \circ \overline{a}_3 \to
j_3^* \circ \overline{a}_3
$$
We split this into two parts. The first is to show that the diagram
$$
\xymatrix{
\overline{a}_1 \ar[r] \ar[d] & \overline{c} \circ \overline{a}_2 \ar[d] \\
\overline{e} \circ \overline{a}_3 \ar[r] &
\overline{c} \circ \overline{d} \circ \overline{a}_3
}
$$
commutes where the lower horizontal arrow comes from the identification
$\overline{e} = \overline{c} \circ \overline{d}$. This is true
because the corresponding diagram of total direct image functors
$$
\xymatrix{
R\overline{f}_{1, *} \ar[r] \ar[d] & Rg_* \circ R\overline{f}_{2, *} \ar[d] \\
R(h \circ g)_* \circ R\overline{f}_{3, *} \ar[r] &
Rg_* \circ Rh_* \circ R\overline{f}_{3, *}
}
$$
is commutative (insert future reference here). The second part
is to show that the composition
$$
j_1^* \circ \overline{c} \circ \overline{d} \to
j_2^* \circ \overline{d} \to j_3^*
$$
is equal to the map
$$
j_1^* \circ \overline{e} \to j_3^*
$$
via the identification $\overline{e} = \overline{c} \circ \overline{d}$.
This was proven in Lemma \ref{lemma-compose-base-change-maps}
(note that in the current case the morphisms $f', g'$ of that
lemma are equal to $\text{id}_X$).
\end{proof}

\begin{lemma}
\label{lemma-upper-shriek-composition}
In Situation \ref{situation-shriek} let $f : X \to Y$ and $g : Y \to Z$
be composable morphisms of $\textit{FTS}_S$. Then there is a canonical
isomorphism $(g \circ f)^! \to f^! \circ g^!$.
\end{lemma}

\begin{proof}
Choose a compactification $i : Y \to \overline{Y}$ of $Y$ over $Z$.
Choose a compactification $X \to \overline{X}$ of $X$ over
$\overline{Y}$. This uses More on Flatness, Theorem \ref{flat-theorem-nagata}
and Lemma \ref{flat-lemma-compactifyable} twice.
Let $\overline{a}$ be the
right adjoint of Lemma \ref{lemma-twisted-inverse-image} for
$\overline{X} \to \overline{Y}$ and let $\overline{b}$
be the
right adjoint of Lemma \ref{lemma-twisted-inverse-image} for
$\overline{Y} \to Z$.
Then $\overline{a} \circ \overline{b}$ is the
right adjoint of Lemma \ref{lemma-twisted-inverse-image} for
the composition $\overline{X} \to Z$.
Hence $g^! = i^* \circ \overline{b}$ and
$(g \circ f)^! = (X \to \overline{X})^* \circ \overline{a} \circ \overline{b}$.
Let $U$ be the inverse image of $Y$ in $\overline{X}$
so that we get the commutative diagram
$$
\xymatrix{
X \ar[r]_j \ar[d] & U \ar[dl] \ar[r]_{j'} & \overline{X} \ar[dl] \\
Y \ar[r]_i \ar[d] & \overline{Y} \ar[dl] \\
Z
}
$$
Let $\overline{a}'$ be the
right adjoint of Lemma \ref{lemma-twisted-inverse-image} for
$U \to Y$.
Then $f^! = j^* \circ \overline{a}'$. We obtain
$$
\gamma : (j')^* \circ \overline{a} \to \overline{a}' \circ i^*
$$
by (\ref{equation-sheafy}) and we can use it to define
$$
(g \circ f)^! =
(j' \circ j)^* \circ \overline{a} \circ \overline{b} =
j^* \circ (j')^* \circ \overline{a} \circ \overline{b}
\to
j^* \circ \overline{a}' \circ i^* \circ \overline{b} =
f^! \circ g^!
$$
which is an isomorphism on objects of $D_\QCoh^+(\mathcal{O}_Z)$ by
Lemma \ref{lemma-proper-noetherian}. To finish the proof we show that
this isomorphism is independent of choices made.

\medskip\noindent
Suppose we have two diagrams
$$
\vcenter{
\xymatrix{
X \ar[r]_{j_1} \ar[d] & U_1 \ar[dl] \ar[r]_{j'_1} & \overline{X}_1 \ar[dl] \\
Y \ar[r]_{i_1} \ar[d] & \overline{Y}_1 \ar[dl] \\
Z
}
}
\quad\text{and}\quad
\vcenter{
\xymatrix{
X \ar[r]_{j_2} \ar[d] & U_2 \ar[dl] \ar[r]_{j'_2} & \overline{X}_2 \ar[dl] \\
Y \ar[r]_{i_2} \ar[d] & \overline{Y}_2 \ar[dl] \\
Z
}
}
$$
We can first choose a compactification $i : Y \to \overline{Y}$
with dense image of $Y$ over $Z$ which dominates both
$\overline{Y}_1$ and $\overline{Y}_2$,
see More on Flatness, Lemma \ref{flat-lemma-compactifications-cofiltered}.
By More on Flatness, Lemma \ref{flat-lemma-right-multiplicative-system} and
Categories, Lemmas \ref{categories-lemma-morphisms-right-localization} and
\ref{categories-lemma-equality-morphisms-right-localization}
we can choose a compactification $X \to \overline{X}$ with dense image of
$X$ over $\overline{Y}$ with morphisms $\overline{X} \to \overline{X}_1$
and $\overline{X} \to \overline{X}_2$ and such that the composition
$\overline{X} \to \overline{Y} \to \overline{Y}_1$ is equal to
the composition $\overline{X} \to \overline{X}_1 \to \overline{Y}_1$
and such that the composition
$\overline{X} \to \overline{Y} \to \overline{Y}_2$ is equal to
the composition $\overline{X} \to \overline{X}_2 \to \overline{Y}_2$.
Thus we see that it suffices to compare the maps
determined by our diagrams when we have a commutative diagram
as follows
$$
\xymatrix{
X \ar[rr]_{j_1} \ar@{=}[d] & &
U_1 \ar[d] \ar[ddll] \ar[rr]_{j'_1} & &
\overline{X}_1 \ar[d] \ar[ddll] \\
X \ar'[r][rr]^-{j_2} \ar[d] & &
U_2 \ar'[dl][ddll] \ar'[r][rr]^-{j'_2} & &
\overline{X}_2 \ar[ddll] \\
Y \ar[rr]^{i_1} \ar@{=}[d] & & \overline{Y}_1 \ar[d] \\
Y \ar[rr]^{i_2} \ar[d] & & \overline{Y}_2 \ar[dll] \\
Z
}
$$
and moreover the compactifications $X \to \overline{X}_1$ and
$Y \to \overline{Y}_2$ have dense image.
We use $\overline{a}_i$, $\overline{a}'_i$, $\overline{c}$, and
$\overline{c}'$ for the
right adjoint of Lemma \ref{lemma-twisted-inverse-image} for
$\overline{X}_i \to \overline{Y}_i$, $U_i \to Y$,
$\overline{X}_1 \to \overline{X}_2$, and $U_1 \to U_2$.
Each of the squares
$$
\xymatrix{
X \ar[r] \ar[d] \ar@{}[dr]|A & U_1 \ar[d] \\
X \ar[r] & U_2
}
\quad
\xymatrix{
U_2 \ar[r] \ar[d] \ar@{}[dr]|B & \overline{X}_2 \ar[d] \\
Y \ar[r] & \overline{Y}_2
}
\quad
\xymatrix{
U_1 \ar[r] \ar[d] \ar@{}[dr]|C & \overline{X}_1 \ar[d] \\
Y \ar[r] & \overline{Y}_1
}
\quad
\xymatrix{
Y \ar[r] \ar[d] \ar@{}[dr]|D & \overline{Y}_1 \ar[d] \\
Y \ar[r] & \overline{Y}_2
}
\quad
\xymatrix{
X \ar[r] \ar[d] \ar@{}[dr]|E & \overline{X}_1 \ar[d] \\
X \ar[r] & \overline{X}_2
}
$$
is cartesian (see
More on Flatness, Lemma \ref{flat-lemma-compactifications-cofiltered} part (c)
for A, D, E and recall that $U_i$ is the inverse image of $Y$
by $\overline{X}_i \to \overline{Y}_i$ for B, C) and hence
gives rise to a base change map (\ref{equation-sheafy}) as follows
$$
\begin{matrix}
\gamma_A : j_1^* \circ \overline{c}' \to j_2^* &
\gamma_B : (j_2')^* \circ \overline{a}_2 \to \overline{a}'_2 \circ i_2^* &
\gamma_C : (j_1')^* \circ \overline{a}_1 \to \overline{a}'_1 \circ i_1^* \\
\gamma_D : i_1^* \circ \overline{d} \to i_2^* &
\gamma_E : (j'_1 \circ j_1)^* \circ \overline{c} \to (j'_2 \circ j_2)^*
\end{matrix}
$$
Denote $f_1^! = j_1^* \circ \overline{a}'_1$,
$f_2^! = j_2^* \circ \overline{a}'_2$,
$g_1^! = i_1^* \circ \overline{b}_1$,
$g_2^! = i_2^* \circ \overline{b}_2$,
$(g \circ f)_1^! =
(j_1' \circ j_1)^* \circ \overline{a}_1 \circ \overline{b}_1$, and
$(g \circ f)^!_2 =
(j_2' \circ j_2)^* \circ \overline{a}_2 \circ \overline{b}_2$.
The construction given in the first paragraph of the proof
and in Lemma \ref{lemma-shriek-well-defined} uses
\begin{enumerate}
\item $\gamma_C$ for the map $(g \circ f)^!_1 \to f_1^! \circ g_1^!$,
\item $\gamma_B$ for the map $(g \circ f)^!_2 \to f_2^! \circ g_2^!$,
\item $\gamma_A$ for the map $f_1^! \to f_2^!$,
\item $\gamma_D$ for the map $g_1^! \to g_2^!$, and
\item $\gamma_E$ for the map $(g \circ f)^!_1 \to (g \circ f)^!_2$.
\end{enumerate}
We have to show that the diagram
$$
\xymatrix{
(g \circ f)^!_1 \ar[r]_{\gamma_E} \ar[d]_{\gamma_C} &
(g \circ f)^!_2 \ar[d]_{\gamma_B} \\
f_1^! \circ g_1^! \ar[r]^{\gamma_A \circ \gamma_D} & f_2^! \circ g_2^!
}
$$
is commutative. We will use
Lemmas \ref{lemma-compose-base-change-maps} and
\ref{lemma-compose-base-change-maps-horizontal}
and with (abuse of) notation as in
Remark \ref{remark-going-around} (in particular
dropping $\star$ products with identity transformations
from the notation).
We can write $\gamma_E = \gamma_A \circ \gamma_F$ where
$$
\xymatrix{
U_1 \ar[r] \ar[d] \ar@{}[rd]|F & \overline{X}_1 \ar[d] \\
U_2 \ar[r] & \overline{X}_2
}
$$
Thus we see that
$$
\gamma_B \circ \gamma_E = \gamma_B \circ \gamma_A  \circ \gamma_F
= \gamma_A \circ \gamma_B \circ \gamma_F
$$
the last equality because the two squares $A$ and $B$ only
intersect in one point (similar to the last argument in
Remark \ref{remark-going-around}). Thus it suffices to prove that
$\gamma_D \circ \gamma_C = \gamma_B \circ \gamma_F$.
Since both of these are equal to the map (\ref{equation-sheafy})
for the square
$$
\xymatrix{
U_1 \ar[r] \ar[d] & \overline{X}_1 \ar[d] \\
Y \ar[r] & \overline{Y}_2
}
$$
we conclude.
\end{proof}

\begin{lemma}
\label{lemma-pseudo-functor}
In Situation \ref{situation-shriek} the constructions of
Lemmas \ref{lemma-shriek-well-defined} and \ref{lemma-upper-shriek-composition}
define a pseudo functor from the category $\textit{FTS}_S$
into the $2$-category of categories (see Categories, Definition
\ref{categories-definition-functor-into-2-category}).
\end{lemma}

\begin{proof}
To show this we have to prove given morphisms
$f : X \to Y$, $g : Y \to Z$, $h : Z \to T$
that
$$
\xymatrix{
(h \circ g \circ f)^! \ar[r]_{\gamma_{A + B}} \ar[d]_{\gamma_{B + C}} &
f^! \circ (h \circ g)^! \ar[d]^{\gamma_C} \\
(g \circ f)^! \circ h^! \ar[r]^{\gamma_A} & f^! \circ g^! \circ h^!
}
$$
is commutative (for the meaning of the $\gamma$'s, see below).
To do this we choose a compactification $\overline{Z}$
of $Z$ over $T$, then a compactification $\overline{Y}$ of $Y$ over
$\overline{Z}$, and then a compactification $\overline{X}$ of
$X$ over $\overline{Y}$. This uses
More on Flatness, Theorem \ref{flat-theorem-nagata} and
Lemma \ref{flat-lemma-compactifyable}.
Let $W \subset \overline{Y}$ be the inverse image of $Z$ under
$\overline{Y} \to \overline{Z}$ and let $U \subset V \subset \overline{X}$
be the inverse images of $Y \subset W$ under $\overline{X} \to \overline{Y}$.
This produces the following diagram
$$
\xymatrix{
X \ar[d]_f \ar[r] & U \ar[r] \ar[d] \ar@{}[dr]|A &
V \ar[d] \ar[r] \ar@{}[rd]|B & \overline{X} \ar[d] \\
Y \ar[d]_g \ar[r] & Y \ar[r] \ar[d] & W \ar[r] \ar[d] \ar@{}[rd]|C &
\overline{Y} \ar[d] \\
Z \ar[d]_h \ar[r] & Z \ar[d] \ar[r] & Z \ar[d] \ar[r] & \overline{Z} \ar[d] \\
T \ar[r] & T \ar[r] & T \ar[r] & T
}
$$
Without introducing tons of notation but arguing exactly
as in the proof of Lemma \ref{lemma-upper-shriek-composition}
we see that the maps in the first displayed diagram use the
maps (\ref{equation-sheafy}) for the rectangles
$A + B$, $B + C$, $A$, and $C$ as indicated. Since by
Lemmas \ref{lemma-compose-base-change-maps} and
\ref{lemma-compose-base-change-maps-horizontal}
we have $\gamma_{A + B} = \gamma_A \circ \gamma_B$ and
$\gamma_{B + C} = \gamma_C \circ \gamma_B$  we conclude
that the desired equality holds provided
$\gamma_A \circ \gamma_C = \gamma_C \circ \gamma_A$.
This is true because the two squares $A$ and $C$ only
intersect in one point (similar to the last argument in
Remark \ref{remark-going-around}).
\end{proof}

\begin{lemma}
\label{lemma-map-pullback-to-shriek-well-defined}
In Situation \ref{situation-shriek} let
$f : X \to Y$ be a morphism of $\textit{FTS}_S$. There are canonical maps
$$
\mu_{f, K} :
Lf^*K \otimes_{\mathcal{O}_X}^\mathbf{L} f^!\mathcal{O}_Y
\longrightarrow
f^!K
$$
functorial in $K$ in $D^+_\QCoh(\mathcal{O}_Y)$.
If $g : Y \to Z$ is another morphism of $\textit{FTS}_S$, then
the diagram
$$
\xymatrix{
Lf^*(Lg^*K \otimes_{\mathcal{O}_Y}^\mathbf{L} g^!\mathcal{O}_Z)
\otimes_{\mathcal{O}_X}^\mathbf{L} f^!\mathcal{O}_Y
\ar@{=}[d] \ar[r]_-{\mu_f} &
f^!(Lg^*K \otimes_{\mathcal{O}_Y}^\mathbf{L} g^!\mathcal{O}_Z)
\ar[r]_-{f^!\mu_g} &
f^!g^!K \ar@{=}[d] \\
Lf^*Lg^*K \otimes_{\mathcal{O}_X}^\mathbf{L} Lf^* g^!\mathcal{O}_Z
\otimes_{\mathcal{O}_X}^\mathbf{L} f^!\mathcal{O}_Y \ar[r]^-{\mu_f} &
Lf^*Lg^*K \otimes_{\mathcal{O}_X}^\mathbf{L} f^!g^!\mathcal{O}_Z
\ar[r]^-{\mu_{g \circ f}} & f^!g^!K
}
$$
commutes for all $K \in D^+_\QCoh(\mathcal{O}_Z)$.
\end{lemma}

\begin{proof}
If $f$ is proper, then $f^! = a$ and we can use
(\ref{equation-compare-with-pullback}) and if $g$ is also proper,
then Lemma \ref{lemma-transitivity-compare-with-pullback} proves
the commutativity of the diagram (in greater generality).

\medskip\noindent
Let us define the map $\mu_{f, K}$. Choose a compactification
$j : X \to \overline{X}$ of $X$ over $Y$. Since $f^!$ is defined
as $j^* \circ \overline{a}$ we obtain $\mu_{f, K}$ as the restriction
of the map (\ref{equation-compare-with-pullback})
$$
L\overline{f}^*K \otimes_{\mathcal{O}_{\overline{X}}}^\mathbf{L}
\overline{a}(\mathcal{O}_Y)
\longrightarrow
\overline{a}(K)
$$
to $X$. To see this is independent of the choice of the compactification
we argue as in the proof of Lemma \ref{lemma-shriek-well-defined}.
We urge the reader to read the proof of that lemma first.

\medskip\noindent
Assume given a morphism $g : \overline{X}_1 \to \overline{X}_2$
between compactifications $j_i : X \to \overline{X}_i$ over $Y$
such that $g^{-1}(j_2(X)) = j_1(X)$. Denote $\overline{c}$ the
right adjoint for pushforward of Lemma \ref{lemma-twisted-inverse-image}
for the morphism $g$. The maps
$$
L\overline{f}_1^*K \otimes_{\mathcal{O}_{\overline{X}}}^\mathbf{L}
\overline{a}_1(\mathcal{O}_Y)
\longrightarrow
\overline{a}_1(K)
\quad\text{and}\quad
L\overline{f}_2^*K \otimes_{\mathcal{O}_{\overline{X}}}^\mathbf{L}
\overline{a}_2(\mathcal{O}_Y)
\longrightarrow
\overline{a}_2(K)
$$
fit into the commutative diagram
$$
\xymatrix{
Lg^*(L\overline{f}_2^*K \otimes^\mathbf{L}
\overline{a}_2(\mathcal{O}_Y))
\otimes^\mathbf{L} \overline{c}(\mathcal{O}_{\overline{X}_2})
\ar@{=}[d] \ar[r]_-\sigma &
\overline{c}(L\overline{f}_2^*K \otimes^\mathbf{L}
\overline{a}_2(\mathcal{O}_Y)) \ar[r] &
\overline{c}(\overline{a}_2(K)) \ar@{=}[d] \\
L\overline{f}_1^*K \otimes^\mathbf{L} Lg^*\overline{a}_2(\mathcal{O}_Y)
\otimes^\mathbf{L} \overline{c}(\mathcal{O}_{\overline{X}_2})
\ar[r]^-{1 \otimes \tau} &
L\overline{f}_1^*K \otimes^\mathbf{L} \overline{a}_1(\mathcal{O}_Y) \ar[r] &
\overline{a}_1(K)
}
$$
by Lemma \ref{lemma-transitivity-compare-with-pullback}. By
Lemma \ref{lemma-compare-on-open} the maps $\sigma$ and $\tau$
restrict to an isomorphism over $X$. In fact, we can say more.
Recall that in the proof of Lemma \ref{lemma-shriek-well-defined} we used
the map (\ref{equation-sheafy}) $\gamma : j_1^* \circ \overline{c} \to j_2^*$
to construct our isomorphism
$\alpha_g : j_1^* \circ \overline{a}_1 \to j_2^* \circ \overline{a}_2$.
Pulling back to map $\sigma$ by $j_1$ we obtain the identity
map on $j_2^*\left(L\overline{f}_2^*K \otimes^\mathbf{L}
\overline{a}_2(\mathcal{O}_Y)\right)$ if we identify
$j_1^*\overline{c}(\mathcal{O}_{\overline{X}_2})$
with $\mathcal{O}_X$ via $j_1^* \circ \overline{c} \to j_2^*$, see
Lemma \ref{lemma-restriction-compare-with-pullback}.
Similarly, the map $\tau : Lg^*\overline{a}_2(\mathcal{O}_Y)
\otimes^\mathbf{L} \overline{c}(\mathcal{O}_{\overline{X}_2}) \to
\overline{a}_1(\mathcal{O}_Y) = \overline{c}(\overline{a}_2(\mathcal{O}_Y))$
pulls back to the identity map on $j_2^*\overline{a}_2(\mathcal{O}_Y)$.
We conclude that pulling back by $j_1$ and applying $\gamma$ wherever
we can we obtain a commutative diagram
$$
\xymatrix{
j_2^*\left(L\overline{f}_2^*K \otimes^\mathbf{L}
\overline{a}_2(\mathcal{O}_Y)\right) \ar[r] \ar[d] &
j_2^*\overline{a}_2(K) \\
j_1^*L\overline{f}_1^*K \otimes^\mathbf{L} j_2^*\overline{a}_2(\mathcal{O}_Y) &
j_1^*(L\overline{f}_1^*K \otimes^\mathbf{L} \overline{a}_1(\mathcal{O}_Y))
\ar[r] \ar[l]_{1 \otimes \alpha_g} &
j_1^* \overline{a}_1(K) \ar[lu]_{\alpha_g}
}
$$
The commutativity of this diagram exactly tells us that the map
$\mu_{f, K}$ constructed using the compactification $\overline{X}_1$
is the same as the map $\mu_{f, K}$ constructed using the compactification
$\overline{X}_2$ via the identification $\alpha_g$ used in the proof
of Lemma \ref{lemma-shriek-well-defined}. Some categorical arguments
exactly as in the proof of  Lemma \ref{lemma-shriek-well-defined}
now show that $\mu_{f, K}$ is well defined (small detail omitted).

\medskip\noindent
Having said this, the commutativity of the diagram in the statement
of our lemma follows from the construction of the isomorphism
$(g \circ f)^! \to f^! \circ g^!$ (first part of the proof of
Lemma \ref{lemma-upper-shriek-composition} using
$\overline{X} \to \overline{Y} \to Z$) and the result
of Lemma \ref{lemma-transitivity-compare-with-pullback}
for $\overline{X} \to \overline{Y} \to Z$.
\end{proof}



\section{Properties of upper shriek functors}
\label{section-upper-shriek-properties}

\noindent
Here are some properties of the upper shriek functors.

\begin{lemma}
\label{lemma-shriek-open-immersion}
In Situation \ref{situation-shriek} let $Y$ be an object
of $\textit{FTS}_S$ and let $j : X \to Y$ be an open immersion.
Then there is a canonical isomorphism $j^! = j^*$ of functors.
\end{lemma}

\noindent
For an \'etale morphism $f : X \to Y$ of $\textit{FTS}_S$
we also have $f^* \cong f^!$, see Lemma \ref{lemma-shriek-etale}.

\begin{proof}
In this case we may choose $\overline{X} = Y$ as our compactification.
Then the
right adjoint of Lemma \ref{lemma-twisted-inverse-image} for
$\text{id} : Y \to Y$ is the
identity functor and hence $j^! = j^*$ by definition.
\end{proof}

\begin{lemma}
\label{lemma-restrict-before-or-after}
In Situation \ref{situation-shriek} let
$$
\xymatrix{
U \ar[r]_j \ar[d]_g & X \ar[d]^f \\
V \ar[r]^{j'} & Y
}
$$
be a commutative diagram of $\textit{FTS}_S$ where $j$ and $j'$ are
open immersions. Then $j^* \circ f^! = g^! \circ (j')^*$ as functors
$D^+_\QCoh(\mathcal{O}_Y) \to D^+(\mathcal{O}_U)$.
\end{lemma}

\begin{proof}
Let $h = f \circ j = j' \circ g$. By
Lemma \ref{lemma-upper-shriek-composition} we have
$h^! = j^! \circ f^! = g^! \circ (j')^!$. By
Lemma \ref{lemma-shriek-open-immersion}
we have $j^! = j^*$ and $(j')^! = (j')^*$.
\end{proof}

\begin{lemma}
\label{lemma-shriek-affine-line}
In Situation \ref{situation-shriek} let $Y$ be an object of $\textit{FTS}_S$
and let $f : X = \mathbf{A}^1_Y \to Y$ be
the projection. Then there is a (noncanonical) isomorphism
$f^!(-) \cong Lf^*(-) [1]$ of functors.
\end{lemma}

\begin{proof}
Since $X = \mathbf{A}^1_Y \subset \mathbf{P}^1_Y$
and since $\mathcal{O}_{\mathbf{P}^1_Y}(-2)|_X \cong \mathcal{O}_X$
this follows from Lemmas \ref{lemma-upper-shriek-P1} and
\ref{lemma-compare-with-pullback-flat-proper-noetherian}.
\end{proof}

\begin{lemma}
\label{lemma-shriek-closed-immersion}
In Situation \ref{situation-shriek} let $Y$ be an object of
$\textit{FTS}_S$ and let $i : X \to Y$ be a closed immersion.
Then there is a canonical isomorphism
$i^!(-) = R\SheafHom(\mathcal{O}_X, -)$ of functors.
\end{lemma}

\begin{proof}
This is a restatement of Lemma \ref{lemma-twisted-inverse-image-closed}.
\end{proof}

\begin{remark}[Local description upper shriek]
\label{remark-local-calculation-shriek}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. Using the lemmas above we can compute
$f^!$ locally as follows. Suppose that we are given affine opens
$$
\xymatrix{
U \ar[r]_j \ar[d]_g & X \ar[d]^f \\
V \ar[r]^i & Y
}
$$
Since $j^! \circ f^! = g^! \circ i^!$
(Lemma \ref{lemma-upper-shriek-composition})
and since $j^!$ and $i^!$ are given by restriction
(Lemma \ref{lemma-shriek-open-immersion})
we see that
$$
(f^!E)|_U = g^!(E|_V)
$$
for any $E \in D^+_\QCoh(\mathcal{O}_X)$. Write
$U = \Spec(A)$ and $V = \Spec(R)$ and let $\varphi : R \to A$
be the finite type ring map corresponding to $g$.
Choose a presentation $A = P/I$ where $P = R[x_1, \ldots, x_n]$
is a polynomial algebra in $n$ variables over $R$. Choose an
object $K \in D^+(R)$ corresponding to $E|_V$
(Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-compare-bounded}).
Then we claim that $f^!E|_U$ corresponds to
$$
\varphi^!(K) = R\Hom(A, K \otimes_R^\mathbf{L} P)[n]
$$
where $R\Hom(A, -) : D(P) \to D(A)$ is the functor of
Dualizing Complexes, Section \ref{dualizing-section-trivial}
and where $\varphi^! : D(R) \to D(A)$ is the functor of
Dualizing Complexes, Section
\ref{dualizing-section-relative-dualizing-complex-algebraic}.
Namely, the choice of presentation
gives a factorization
$$
U \rightarrow \mathbf{A}^n_V \to \mathbf{A}^{n - 1}_V \to \ldots \to
\mathbf{A}^1_V \to V
$$
Applying Lemma \ref{lemma-shriek-affine-line} exactly $n$ times we see that
$(\mathbf{A}^n_V \to V)^!(E|_V)$ corresponds to
$K \otimes_R^\mathbf{L} P[n]$. By Lemmas
\ref{lemma-sheaf-with-exact-support-quasi-coherent} and
\ref{lemma-shriek-closed-immersion} the last step corresponds to
applying $R\Hom(A, -)$.
\end{remark}

\begin{lemma}
\label{lemma-shriek-coherent}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. Then $f^!$ maps
$D_{\textit{Coh}}^+(\mathcal{O}_Y)$ into $D_{\textit{Coh}}^+(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
The question is local on $X$ hence we may assume that $X$ and $Y$ are
affine schemes. In this case we can factor $f : X \to Y$ as
$$
X \xrightarrow{i} \mathbf{A}^n_Y \to \mathbf{A}^{n - 1}_Y \to \ldots \to
\mathbf{A}^1_Y \to Y
$$
where $i$ is a closed immersion. The lemma follows from
By Lemmas \ref{lemma-shriek-affine-line} and
\ref{lemma-sheaf-with-exact-support-coherent} and
Dualizing Complexes, Lemma
\ref{dualizing-lemma-dualizing-polynomial-ring}
and induction.
\end{proof}

\begin{lemma}
\label{lemma-shriek-dualizing}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. If $K$ is a dualizing complex
for $Y$, then $f^!K$ is a dualizing complex for $X$.
\end{lemma}

\begin{proof}
The question is local on $X$ hence we may assume that $X$ and $Y$ are
affine schemes. In this case we can factor $f : X \to Y$ as
$$
X \xrightarrow{i} \mathbf{A}^n_Y \to \mathbf{A}^{n - 1}_Y \to \ldots \to
\mathbf{A}^1_Y \to Y
$$
where $i$ is a closed immersion. By Lemma \ref{lemma-shriek-affine-line} and
Dualizing Complexes, Lemma \ref{dualizing-lemma-dualizing-polynomial-ring}
and induction we see that
the $p^!K$ is a dualizing complex on $\mathbf{A}^n_Y$ where
$p : \mathbf{A}^n_Y \to Y$ is the projection. Similarly, by
Dualizing Complexes, Lemma \ref{dualizing-lemma-dualizing-quotient}
and Lemmas
\ref{lemma-sheaf-with-exact-support-quasi-coherent} and
\ref{lemma-shriek-closed-immersion} we see that $i^!$
transforms dualizing complexes into dualizing complexes.
\end{proof}

\begin{lemma}
\label{lemma-shriek-via-duality}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. Let $K$ be a dualizing complex
on $Y$. Set $D_Y(M) = R\SheafHom_{\mathcal{O}_Y}(M, K)$ for
$M \in D_{\textit{Coh}}(\mathcal{O}_Y)$ and
$D_X(E) = R\SheafHom_{\mathcal{O}_X}(E, f^!K)$ for
$E \in D_{\textit{Coh}}(\mathcal{O}_X)$. Then there is a canonical
isomorphism
$$
f^!M \longrightarrow D_X(Lf^*D_Y(M))
$$
for $M \in D_{\textit{Coh}}^+(\mathcal{O}_Y)$.
\end{lemma}

\begin{proof}
Choose compactification $j : X \subset \overline{X}$ of $X$ over $Y$
(More on Flatness, Theorem \ref{flat-theorem-nagata} and
Lemma \ref{flat-lemma-compactifyable}). Let $a$ be the
right adjoint of Lemma \ref{lemma-twisted-inverse-image} for
$\overline{X} \to Y$. Set
$D_{\overline{X}}(E) = R\SheafHom_{\mathcal{O}_{\overline{X}}}(E, a(K))$
for $E \in D_{\textit{Coh}}(\mathcal{O}_{\overline{X}})$.
Since formation of $R\SheafHom$ commutes with restriction to opens
and since $f^! = j^* \circ a$ we see that it suffices to prove that
there is a canonical isomorphism
$$
a(M) \longrightarrow D_{\overline{X}}(L\overline{f}^*D_Y(M))
$$
for $M \in D_{\textit{Coh}}(\mathcal{O}_Y)$. For
$F \in D_\QCoh(\mathcal{O}_X)$ we have
\begin{align*}
\Hom_{\overline{X}}(
F, D_{\overline{X}}(L\overline{f}^*D_Y(M)))
& =
\Hom_{\overline{X}}(
F \otimes_{\mathcal{O}_X}^\mathbf{L} L\overline{f}^*D_Y(M), a(K)) \\
& =
\Hom_Y(
R\overline{f}_*(F \otimes_{\mathcal{O}_X}^\mathbf{L} L\overline{f}^*D_Y(M)),
K) \\
& =
\Hom_Y(
R\overline{f}_*(F) \otimes_{\mathcal{O}_Y}^\mathbf{L} D_Y(M),
K) \\
& =
\Hom_Y(
R\overline{f}_*(F), D_Y(D_Y(M))) \\
& =
\Hom_Y(R\overline{f}_*(F), M) \\
& = \Hom_{\overline{X}}(F, a(M))
\end{align*}
The first equality by Cohomology, Lemma \ref{cohomology-lemma-internal-hom}.
The second by definition of $a$.
The third by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-cohomology-base-change}.
The fourth equality by Cohomology, Lemma \ref{cohomology-lemma-internal-hom}
and the definition of $D_Y$.
The fifth equality by Lemma \ref{lemma-dualizing-schemes}.
The final equality by definition of $a$.
Hence we see that $a(M) = D_{\overline{X}}(L\overline{f}^*D_Y(M))$
by Yoneda's lemma.
\end{proof}

\begin{lemma}
\label{lemma-perfect-comparison-shriek}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. Assume $f$ is perfect (e.g., flat). Then
\begin{enumerate}
\item[(a)] $f^!\mathcal{O}_Y$ is in $D_{\textit{Coh}}^b(\mathcal{O}_X)$,
\item[(b)] $f^!\mathcal{O}_Y$ has finite tor dimension in
$D(f^{-1}\mathcal{O}_Y)$,
\item[(c)] $\mathcal{O}_X \to
R\SheafHom_{\mathcal{O}_X}(f^!\mathcal{O}_Y, f^!\mathcal{O}_Y)$
is an isomorphism,
\item[(d)] $f^!$ maps $D_{\textit{Coh}}^b(\mathcal{O}_Y)$ into
$D_{\textit{Coh}}^b(\mathcal{O}_X)$,
\item[(e)] the map
$\mu_{f,  K} :
Lf^*K \otimes_{\mathcal{O}_X}^\mathbf{L} f^!\mathcal{O}_Y
\to
f^!K$
of Lemma \ref{lemma-map-pullback-to-shriek-well-defined}
is an isomorphism for all $K \in D_\QCoh^+(\mathcal{O}_Y)$.
\end{enumerate}
\end{lemma}

\begin{proof}
(A flat morphism of finite presentation is perfect, see
More on Morphisms, Lemma
\ref{more-morphisms-lemma-flat-finite-presentation-perfect}.)
Assertions (a), (b), and (c) are local on $X$.
Thus we may assume $X$ and $Y$ are affine.
Then Remark \ref{remark-local-calculation-shriek}
turns (a), (b), and (c) into (1)(a), (1)(b), and (1)(c) of
Dualizing Complexes, Lemma \ref{dualizing-lemma-relative-dualizing-algebraic}.
(Use Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-tor-dimension-rel-affine},
\ref{perfect-lemma-pseudo-coherent},
\ref{perfect-lemma-identify-pseudo-coherent-noetherian}
\ref{perfect-lemma-quasi-coherence-internal-hom} to match the assertions.)

\medskip\noindent
To prove (d) and (e) we begin with a series of preliminary remarks.
\begin{enumerate}
\item We already know that $f^!$ sends $D_{\textit{Coh}}^+(\mathcal{O}_Y)$
into $D_{\textit{Coh}}^+(\mathcal{O}_X)$, see
Lemma \ref{lemma-shriek-coherent}.
\item If $f$ is an open immersion, then $f^! = f^*$ and (d) and (e)
are true because we can take $\overline{X} = Y$ in the construction
of $f^!$ and $\mu_f$, see Lemma \ref{lemma-shriek-open-immersion}.
\item If $f$ is a perfect proper morphism, then (e) is true by
Lemma \ref{lemma-compare-with-pullback-flat-proper-noetherian}.
\item If there exists an open covering $X = \bigcup U_i$ and (d) is
true for $U_i \to Y$, then (d) is true for $X \to Y$. Same for (e).
This holds because the construction of $f^!$ and $\mu_f$ commutes
with passing to open subschemes.
\item If $g : Y \to Z$ is a second perfect morphism in $\textit{FTS}_S$
and (e) holds for $f$ and $g$, then
$f^!g^!\mathcal{O}_Z =
Lf^*g^!\mathcal{O}_Z \otimes_{\mathcal{O}_X}^\mathbf{L} f^!\mathcal{O}_Y$
and (e) holds for $g \circ f$ by the commutative diagram
of Lemma \ref{lemma-map-pullback-to-shriek-well-defined}.
\item If (d) and (e) hold for both $f$ and $g$, then
(d) and (e) hold for $g \circ f$. Namely, then $f^!g^!\mathcal{O}_Z$
is bounded above (by the previous point) and $L(g \circ f)^*$ has finite
cohomological dimension and (d) follows from (e) which we saw above.
\end{enumerate}
From these points we see it suffices to prove (d) and (e) in case $X$ is
affine. Choose an immersion $X \to \mathbf{A}^n_Y$
(Morphisms, Lemma \ref{morphisms-lemma-quasi-affine-finite-type-over-S})
which we factor as $X \to U \to \mathbf{A}^n_Y \to Y$ where $X \to U$
is a closed immersion and $U \subset \mathbf{A}^n_Y$ is open.
Note that $X \to U$ is a perfect closed immersion by
More on Morphisms, Lemma \ref{more-morphisms-lemma-perfect-permanence}.
Thus it suffices to prove the lemma for a perfect closed immersion
and for the projection $\mathbf{A}^n_Y \to Y$.

\medskip\noindent
Let $f : X \to Y$ be a perfect closed immersion. We already know (d) holds.
Let $K \in D^b_{\textit{Coh}}(\mathcal{O}_Y)$.
Then $f^!K = R\SheafHom(\mathcal{O}_X, K)$
(Lemma \ref{lemma-shriek-closed-immersion})
and $f_*f^!K = R\SheafHom_{\mathcal{O}_Y}(f_*\mathcal{O}_X, K)$.
Since $f$ is perfect, the complex $f_*\mathcal{O}_X$ is perfect
and hence $R\SheafHom_{\mathcal{O}_Y}(f_*\mathcal{O}_X, K)$ is bounded above.
This proves that (d) holds. Some details omitted.

\medskip\noindent
Let $f : \mathbf{A}^n_Y \to Y$ be the projection. Then (d) holds
by repeated application of Lemma \ref{lemma-shriek-affine-line}.
Finally, (e) is true because it holds for $\mathbf{P}^n_Y \to Y$
(flat and proper) and because $\mathbf{A}^n_Y \subset \mathbf{P}^n_Y$
is an open.
\end{proof}

\begin{lemma}
\label{lemma-flat-shriek-relatively-perfect}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. If $f$ is flat, then
$f^!\mathcal{O}_Y$ is a $Y$-perfect object of $D(\mathcal{O}_X)$ and
$\mathcal{O}_X \to
R\SheafHom_{\mathcal{O}_X}(f^!\mathcal{O}_Y, f^!\mathcal{O}_Y)$
is an isomorphism.
\end{lemma}

\begin{proof}
Both assertions are local on $X$. Thus we may assume $X$ and $Y$ are
affine. Then Remark \ref{remark-local-calculation-shriek}
turns the lemma into an algebra lemma, namely
Dualizing Complexes, Lemma \ref{dualizing-lemma-relative-dualizing-algebraic}.
(Use Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-locally-rel-perfect} to match the languages.)
\end{proof}

\begin{lemma}
\label{lemma-lci-shriek}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. Assume $f : X \to Y$ is a local complete
intersection morphism. Then
\begin{enumerate}
\item $f^!\mathcal{O}_Y$ is an invertible object of $D(\mathcal{O}_X)$, and
\item $f^!$ maps perfect complexes to perfect complexes.
\end{enumerate}
\end{lemma}

\begin{proof}
Recall that a local complete intersection morphism is perfect, see
More on Morphisms, Lemma \ref{more-morphisms-lemma-lci-properties}.
By Lemma \ref{lemma-perfect-comparison-shriek} it suffices to show
that $f^!\mathcal{O}_Y$ is an invertible object in $D(\mathcal{O}_X)$.
This question is local on $X$ and $Y$. Hence we may assume that $X \to Y$
factors as $X \to \mathbf{A}^n_Y \to Y$ where the first arrow is a
Koszul regular immersion. See More on Morphisms, Section
\ref{more-morphisms-section-lci}.
The result holds for $\mathbf{A}^n_Y \to Y$
by Lemma \ref{lemma-shriek-affine-line}. Thus it suffices to prove
the lemma when $f$ is a Koszul regular immersion.
Working locally once again we reduce to the case
$X = \Spec(A)$ and $Y = \Spec(B)$, where $A = B/(f_1, \ldots, f_r)$
for some regular sequence $f_1, \ldots, f_r \in B$
(use that for Noetherian local rings the notion of Koszul
regular and regular are the same, see
More on Algebra, Lemma
\ref{more-algebra-lemma-noetherian-finite-all-equivalent}).
Thus $X \to Y$ is a composition
$$
X = X_r \to X_{r - 1} \to \ldots \to X_1 \to X_0 = Y
$$
where each arrow is the inclusion of an effective Cartier divisor.
In this way we reduce to the case of an inclusion of an effective
Cartier divisor $i : D \to X$. In this case
$i^!\mathcal{O}_X = \mathcal{N}[1]$ by
Lemma \ref{lemma-compute-for-effective-Cartier} and the proof is complete.
\end{proof}







\section{Base change for upper shriek}
\label{section-base-change-shriek}

\noindent
In Situation \ref{situation-shriek} let
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d]_{f'} & X \ar[d]^f \\
Y' \ar[r]^g & Y
}
$$
be a cartesian diagram in $\textit{FTS}_S$ such that
$X$ and $Y'$ are Tor independent over $Y$. Our setup is currently
not sufficient to construct a base change map
$L(g')^* \circ f^! \to (f')^! \circ Lg^*$ in this generality.
The reason is that in general it will not be possible to choose
a compactification $j : X \to \overline{X}$ over $Y$ such that
$\overline{X}$ and $Y'$ are tor independent over $Y$ and hence
our construction of the base change map in
Section \ref{section-base-change-map} does not apply\footnote{
The reader who is well versed with derived algebraic geometry
will realize this is not a ``real'' problem. Namely, taking
$\overline{X}'$ to be the derived fibre product of
$\overline{X}$ and $Y'$ over $Y$, one can argue exactly as in
the proof of Lemma \ref{lemma-base-change-shriek-flat}
to define this map. After all, the Tor independence
of $X$ and $Y'$ guarantees that $X'$ will be an open subscheme
of the derived scheme $\overline{X}'$.}.

\medskip\noindent
A partial remedy will be found in
Section \ref{section-relative-dualizing-complexes}.
Namely, if the morphism $f$ is flat, then there is a good
notion of a relative dualizing complex and using
Lemmas \ref{lemma-compactifyable-relative-dualizing}
\ref{lemma-base-change-relative-dualizing},
and \ref{lemma-perfect-comparison-shriek}
we may construct a canonical base change isomorphism.
If we ever need to use this, we will add precise statements and
proofs later in this chapter.

\begin{lemma}
\label{lemma-base-change-shriek-flat}
In Situation \ref{situation-shriek} let
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d]_{f'} & X \ar[d]^f \\
Y' \ar[r]^g & Y
}
$$
be a cartesian diagram of $\textit{FTS}_S$ with $g$ flat.
Then there is an isomorphism
$L(g')^* \circ f^! \to (f')^! \circ Lg^*$ on
$D_\QCoh^+(\mathcal{O}_Y)$.
\end{lemma}

\begin{proof}
Namely, because $g$ is flat, for every choice of
compactification $j : X \to \overline{X}$ of $X$ over $Y$
the scheme $\overline{X}$ is Tor independent of $Y'$.
Denote $j' : X' \to \overline{X}'$ the
base change of $j$ and $\overline{g}' : \overline{X}' \to \overline{X}$
the projection. We define the base change map as the composition
$$
L(g')^* \circ f^! = L(g')^* \circ j^* \circ a =
(j')^* \circ L(\overline{g}')^* \circ a \longrightarrow
(j')^* \circ a' \circ Lg^* = (f')^! \circ Lg^*
$$
where the middle arrow is the base change map
(\ref{equation-base-change-map})
and $a$ and $a'$ are the right adjoints to pushforward
of Lemma \ref{lemma-twisted-inverse-image}
for $\overline{X} \to Y$ and $\overline{X}' \to Y'$.
This construction is independent of the choice of
compactification (we will formulate a precise lemma
and prove it, if we ever need this result).

\medskip\noindent
To finish the proof it suffices to show that the base change
map $L(g')^* \circ a \to a' \circ Lg^*$ is an isomorphism
on $D_\QCoh^+(\mathcal{O}_Y)$.
By Lemma \ref{lemma-proper-noetherian} formation of $a$ and $a'$
commutes with restriction to affine opens of $Y$ and $Y'$.
Thus by Remark \ref{remark-check-over-affines}
we may assume that $Y$ and $Y'$ are affine.
Thus the result by Lemma \ref{lemma-more-base-change}.
\end{proof}

\begin{lemma}
\label{lemma-shriek-etale}
In Situation \ref{situation-shriek} let $f : X \to Y$ be an \'etale
morphism of $\textit{FTS}_S$. Then $f^! \cong f^*$ as functors on
$D^+_\QCoh(\mathcal{O}_Y)$.
\end{lemma}

\begin{proof}
We are going to use that an \'etale morphism is flat, syntomic,
and a local complete intersection morphism
(Morphisms, Lemma \ref{morphisms-lemma-etale-syntomic} and
\ref{morphisms-lemma-etale-flat} and
More on Morphisms, Lemma \ref{more-morphisms-lemma-flat-lci}).
By Lemma \ref{lemma-perfect-comparison-shriek} it suffices
to show $f^!\mathcal{O}_Y = \mathcal{O}_X$.
By Lemma \ref{lemma-lci-shriek} we know that $f^!\mathcal{O}_Y$
is an invertible module. Consider the commutative diagram
$$
\xymatrix{
X \times_Y X \ar[r]_{p_2} \ar[d]_{p_1} & X \ar[d]^f \\
X \ar[r]^f & Y
}
$$
and the diagonal $\Delta : X \to X \times_Y X$. Since $\Delta$
is an open immersion (by Morphisms, Lemmas
\ref{morphisms-lemma-diagonal-unramified-morphism} and
\ref{morphisms-lemma-etale-smooth-unramified}), by
Lemma \ref{lemma-shriek-open-immersion} we have $\Delta^! = \Delta^*$.
By Lemma \ref{lemma-upper-shriek-composition} we have
$\Delta^! \circ p_1^! \circ f^! = f^!$.
By Lemma \ref{lemma-base-change-shriek-flat} applied to
the diagram we have $p_1^!\mathcal{O}_X = p_2^*f^!\mathcal{O}_Y$.
Hence we conclude
$$
f^!\mathcal{O}_Y = \Delta^!p_1^!f^!\mathcal{O}_Y =
\Delta^*(p_1^*f^!\mathcal{O}_Y \otimes p_1^!\mathcal{O}_X) =
\Delta^*(p_2^*f^!\mathcal{O}_Y \otimes p_1^*f^!\mathcal{O}_Y) =
(f^!\mathcal{O}_Y)^{\otimes 2}
$$
where in the second step we have used
Lemma \ref{lemma-perfect-comparison-shriek} once more.
Thus $f^!\mathcal{O}_Y = \mathcal{O}_X$ as desired.
\end{proof}


\noindent
In the rest of this section, we formulate some easy to prove
results which would be consequences of a good theory of the
base change map.

\begin{lemma}[Makeshift base change]
\label{lemma-base-change-locally}
In Situation \ref{situation-shriek} let
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d]_{f'} & X \ar[d]^f \\
Y' \ar[r]^g & Y
}
$$
be a cartesian diagram of $\textit{FTS}_S$.
Let $E \in D^+_\QCoh(\mathcal{O}_Y)$ be an object
such that $Lg^*E$ is in $D^+(\mathcal{O}_Y)$.
If $f$ is flat, then $L(g')^*f^!E$ and $(f')^!Lg^*E$
restrict to isomorphic objects of $D(\mathcal{O}_{U'})$
for $U' \subset X'$ affine open mapping into affine opens of $Y$, $Y'$, and $X$.
\end{lemma}

\begin{proof}
By our assumptions we immediately reduce to the case where
$X$, $Y$, $Y'$, and $X'$ are affine.
Say $Y = \Spec(R)$, $Y' = \Spec(R')$, $X = \Spec(A)$, and $X' = \Spec(A')$.
Then $A' = A \otimes_R R'$. Let
$E$ correspond to $K \in D^+(R)$.
Denoting $\varphi : R \to A$ and $\varphi' : R' \to A'$
the given maps we see from
Remark \ref{remark-local-calculation-shriek}
that $L(g')^*f^!E$ and $(f')^!Lg^*E$ correspond to
$\varphi^!(K) \otimes_A^\mathbf{L} A'$ and
$(\varphi')^!(K \otimes_R^\mathbf{L} R')$
where $\varphi^!$ and $(\varphi')^!$ are the functors from
Dualizing Complexes, Section
\ref{dualizing-section-relative-dualizing-complex-algebraic}.
The result follows from
Dualizing Complexes, Lemma \ref{dualizing-lemma-bc-flat}.
\end{proof}

\begin{lemma}
\label{lemma-relative-dualizing-fibres}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. Assume $f$ is flat. Set
$\omega_{X/Y}^\bullet = f^!\mathcal{O}_Y$ in $D^b_{\textit{Coh}}(X)$.
Let $y \in Y$ and $h : X_y \to X$ the projection.
Then $Lh^*\omega_{X/Y}^\bullet$ is a dualizing complex
on $X_y$.
\end{lemma}

\begin{proof}
The complex $\omega_{X/Y}^\bullet$ is in $D^b_{\textit{Coh}}$
by Lemma \ref{lemma-perfect-comparison-shriek}.
Being a dualizing complex is a local property.
Hence by Lemma \ref{lemma-base-change-locally}
it suffices to show that $(X_y \to y)^!\mathcal{O}_y$
is a dualizing complex on $X_y$.
This follows from Lemma \ref{lemma-shriek-dualizing}.
\end{proof}








\section{A duality theory}
\label{section-duality}

\noindent
In this section we spell out what kind of a duality theory our very general
results above give for finite type separated schemes over a fixed
Noetherian base scheme.

\medskip\noindent
Recall that a dualizing complex on a Noetherian scheme $X$, is an
object of $D(\mathcal{O}_X)$ which affine locally gives a dualizing
complex for the corresponding rings, see
Definition \ref{definition-dualizing-scheme}.

\medskip\noindent
Given a Noetherian scheme $S$ denote $\textit{FTS}_S$ the category
of schemes which are of finite type and separated over $S$. Then:
\begin{enumerate}
\item the functors $f^!$ turn $D_\QCoh^+$ into a pseudo functor
on $\textit{FTS}_S$,
\item if $f : X \to Y$ is a proper morphism in $\textit{FTS}_S$,
then $f^!$ is the restriction of the right adjoint of
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$
to $D_\QCoh^+(\mathcal{O}_Y)$ and there is a canonical isomorphism
$$
Rf_*R\SheafHom_{\mathcal{O}_X}(K, f^!M)
\to
R\SheafHom_{\mathcal{O}_Y}(Rf_*K, M)
$$
for all $K \in D_{\textit{Coh}}^-(\mathcal{O}_X)$ and
$M \in D_\QCoh^+(\mathcal{O}_Y)$,
\item if an object $X$ of $\textit{FTS}_S$ has a dualizing complex
$\omega_X^\bullet$, then the functor
$D_X = R\SheafHom_{\mathcal{O}_X}(-, \omega_X^\bullet)$
defines an involution of $D_{\textit{Coh}}(\mathcal{O}_X)$
switching $D_{\textit{Coh}}^+(\mathcal{O}_X)$ and
$D_{\textit{Coh}}^-(\mathcal{O}_X)$ and fixing
$D_{\textit{Coh}}^b(\mathcal{O}_X)$,
\item if $f : X \to Y$ is a morphism of $\textit{FTS}_S$
and $\omega_Y^\bullet$ is a dualizing complex on $Y$, then
\begin{enumerate}
\item $\omega_X^\bullet = f^!\omega_Y^\bullet$ is a dualizing complex for $X$,
\item $f^!M = D_X(Lf^*D_Y(M))$ canonically for
$M \in D_{\textit{Coh}}^+(\mathcal{O}_Y)$, and
\item if in addition $f$ is proper then
$$
Rf_*R\SheafHom_{\mathcal{O}_X}(K, \omega_X^\bullet) =
R\SheafHom_{\mathcal{O}_Y}(Rf_*K, \omega_Y^\bullet)
$$
for $K$ in $D^-_{\textit{Coh}}(\mathcal{O}_X)$,
\end{enumerate}
\item if $f : X \to Y$ is a closed immersion in $\textit{FTS}_S$,
then $f^!(-) = R\SheafHom(\mathcal{O}_X, -)$,
\item if $f : Y \to X$ is a finite morphism in $\textit{FTS}_S$,
then $f_*f^!(-) = R\SheafHom_{\mathcal{O}_X}(f_*\mathcal{O}_Y, -)$,
\item if $f : X \to Y$ is the inclusion of an effective Cartier divisor
into an object of $\textit{FTS}_S$, then
$f^!(-) = Lf^*(-) \otimes_{\mathcal{O}_X} f^*\mathcal{O}_Y(X)[-1]$,
\item if $f : X \to Y$ is a Koszul regular immersion of codimension $c$
into an object of $\textit{FTS}_S$, then
$f^!(-) \cong Lf^*(-) \otimes_{\mathcal{O}_X} \wedge^c\mathcal{N}[-c]$, and
\item if $f : X \to Y$ is a smooth proper morphism of relative dimension $d$
in $\textit{FTS}_S$, then
$f^!(-) \cong Lf^*(-)  \otimes_{\mathcal{O}_X} \Omega^d_{X/Y}[d]$.
\end{enumerate}
This follows from Lemmas
\ref{lemma-dualizing-schemes},
\ref{lemma-iso-on-RSheafHom},
\ref{lemma-twisted-inverse-image-closed},
\ref{lemma-finite-twisted},
\ref{lemma-sheaf-with-exact-support-effective-Cartier},
\ref{lemma-regular-immersion},
\ref{lemma-smooth-proper},
\ref{lemma-upper-shriek-composition},
\ref{lemma-pseudo-functor},
\ref{lemma-shriek-closed-immersion},
\ref{lemma-shriek-dualizing},
\ref{lemma-shriek-via-duality}, and
\ref{lemma-perfect-comparison-shriek} and
Example \ref{example-iso-on-RSheafHom-noetherian}.
We have obtained our functors by a very abstract procedure
which finally rests on invoking an existence theorem
(Derived Categories, Proposition \ref{derived-proposition-brown}).
This means we have, in general, no explicit description of the functors $f^!$.
This can sometimes be a problem. But in fact, it is often enough to know
the existence of a dualizing complex and the duality isomorphism
to pin down $f^!$.






\section{Glueing dualizing complexes}
\label{section-glue}

\noindent
We will now use glueing of dualizing complexes to get a theory which works for
all finite type schemes over $S$ given a pair $(S, \omega_S^\bullet)$
as in Situation \ref{situation-dualizing}. This is similar to
\cite[Remark on page 310]{RD}.

\begin{situation}
\label{situation-dualizing}
Here $S$ is a Noetherian scheme and $\omega_S^\bullet$ is a dualizing
complex.
\end{situation}

\noindent
In Situation \ref{situation-dualizing} let $X$ be a scheme of finite type
over $S$. Let $\mathcal{U} : X = \bigcup_{i = 1, \ldots, n} U_i$
be a finite open covering of $X$ by objects of $\textit{FTS}_S$, see
Situation \ref{situation-shriek}. All this means is that the morphisms
$U_i \to S$ are separated (as they are already of finite type).
Every affine scheme of finite type over $S$ is an object of $\textit{FTS}_S$
by Schemes, Lemma \ref{schemes-lemma-compose-after-separated}
hence such open coverings certainly exist.
Then for each $i, j, k \in \{1, \ldots, n\}$
the morphisms $p_i : U_i \to S$, $p_{ij} : U_i \cap U_j \to S$,
and $p_{ijk} : U_i \cap U_j \cap U_k \to S$ are separated and
each of these schemes is an object of $\textit{FTS}_S$.
From such an open covering we obtain
\begin{enumerate}
\item $\omega_i^\bullet = p_i^!\omega_S^\bullet$
a dualizing complex on $U_i$, see Section \ref{section-duality},
\item for each $i, j$ a canonical isomorphism
$\varphi_{ij} :
\omega_i^\bullet|_{U_i \cap U_j} \to \omega_j^\bullet|_{U_i \cap U_j}$, and
\item
\label{item-cocycle-glueing}
for each $i, j, k$ we have
$$
\varphi_{ik}|_{U_i \cap U_j \cap U_k} =
\varphi_{jk}|_{U_i \cap U_j \cap U_k} \circ
\varphi_{ij}|_{U_i \cap U_j \cap U_k}
$$
in $D(\mathcal{O}_{U_i \cap U_j \cap U_k})$.
\end{enumerate}
Here, in (2) we use that $(U_i \cap U_j \to U_i)^!$
is given by restriction (Lemma \ref{lemma-shriek-open-immersion})
and that we have canonical isomorphisms
$$
(U_i \cap U_j \to U_i)^! \circ p_i^! = p_{ij}^! =
(U_i \cap U_j \to U_j)^! \circ p_j^!
$$
by Lemma \ref{lemma-upper-shriek-composition} and to get (3) we use
that the upper shriek functors form a pseudo functor by
Lemma \ref{lemma-pseudo-functor}.

\medskip\noindent
In the situation just described a
{\it dualizing complex normalized relative to $\omega_S^\bullet$
and $\mathcal{U}$} is a pair $(K, \alpha_i)$ where $K \in D(\mathcal{O}_X)$
and $\alpha_i : K|_{U_i} \to \omega_i^\bullet$ are isomorphisms
such that $\varphi_{ij}$ is given by
$\alpha_j|_{U_i \cap U_j} \circ \alpha_i^{-1}|_{U_i \cap U_j}$.
Since being a dualizing complex on a scheme is a local property
we see that dualizing complexes normalized relative to $\omega_S^\bullet$
and $\mathcal{U}$ are indeed dualizing complexes.

\begin{lemma}
\label{lemma-good-dualizing-unique}
In Situation \ref{situation-dualizing} let $X$ be a scheme of finite type
over $S$ and let $\mathcal{U}$ be a finite open covering of $X$
by schemes separated over $S$. If there exists a dualizing complex
normalized relative to $\omega_S^\bullet$ and $\mathcal{U}$, then it is unique
up to unique isomorphism.
\end{lemma}

\begin{proof}
If $(K, \alpha_i)$ and $(K', \alpha_i')$ are two, then we consider
$L = R\SheafHom_{\mathcal{O}_X}(K, K')$.
By Lemma \ref{lemma-dualizing-unique-schemes}
and its proof, this is an invertible object of $D(\mathcal{O}_X)$.
Using $\alpha_i$ and $\alpha'_i$ we obtain an isomorphism
$$
\alpha_i^t \otimes \alpha'_i :
L|_{U_i} \longrightarrow
R\SheafHom_{\mathcal{O}_X}(\omega_i^\bullet, \omega_i^\bullet) =
\mathcal{O}_{U_i}[0]
$$
This already implies that $L = H^0(L)[0]$ in $D(\mathcal{O}_X)$.
Moreover, $H^0(L)$ is an invertible sheaf with given trivializations
on the opens $U_i$ of $X$. Finally, the condition that
$\alpha_j|_{U_i \cap U_j} \circ \alpha_i^{-1}|_{U_i \cap U_j}$
and
$\alpha'_j|_{U_i \cap U_j} \circ (\alpha'_i)^{-1}|_{U_i \cap U_j}$
both give $\varphi_{ij}$ implies that the transition maps
are $1$ and we get an isomorphism $H^0(L) = \mathcal{O}_X$.
\end{proof}

\begin{lemma}
\label{lemma-good-dualizing-independence-covering}
In Situation \ref{situation-dualizing} let $X$ be a scheme of finite type
over $S$ and let $\mathcal{U}$, $\mathcal{V}$ be two finite open coverings
of $X$ by schemes separated over $S$.
If there exists a dualizing complex normalized
relative to $\omega_S^\bullet$ and $\mathcal{U}$, then
there exists a dualizing complex normalized relative to
$\omega_S^\bullet$ and $\mathcal{V}$ and these complexes are
canonically isomorphic.
\end{lemma}

\begin{proof}
It suffices to prove this when $\mathcal{U}$ is given by the opens
$U_1, \ldots, U_n$ and $\mathcal{V}$ by the opens $U_1, \ldots, U_{n + m}$.
In fact, we may and do even assume $m = 1$.
To go from a dualizing complex $(K, \alpha_i)$ normalized
relative to $\omega_S^\bullet$ and $\mathcal{V}$ to a
dualizing complex normalized relative to $\omega_S^\bullet$ and $\mathcal{U}$
is achieved by forgetting about $\alpha_i$ for $i = n + 1$. Conversely, let
$(K, \alpha_i)$ be a dualizing complex normalized relative to
$\omega_S^\bullet$ and $\mathcal{U}$.
To finish the proof we need to construct a map
$\alpha_{n + 1} : K|_{U_{n + 1}} \to \omega_{n + 1}^\bullet$ satisfying
the desired conditions.
To do this we observe that $U_{n + 1} = \bigcup U_i \cap U_{n + 1}$
is an open covering.
It is clear that $(K|_{U_{n + 1}}, \alpha_i|_{U_i \cap U_{n + 1}})$
is a dualizing complex normalized relative to $\omega_S^\bullet$
and the covering $U_{n + 1} = \bigcup U_i \cap U_{n + 1}$.
On the other hand, by condition (\ref{item-cocycle-glueing}) the pair
$(\omega_{n + 1}^\bullet|_{U_{n + 1}}, \varphi_{n + 1i})$
is another dualizing complex normalized relative to $\omega_S^\bullet$
and the covering
$U_{n + 1} = \bigcup U_i \cap U_{n + 1}$.
By Lemma \ref{lemma-good-dualizing-unique} we obtain a unique isomorphism
$$
\alpha_{n + 1} : K|_{U_{n + 1}} \longrightarrow \omega_{n + 1}^\bullet
$$
compatible with the given local isomorphisms.
It is a pleasant exercise to show that this means it satisfies
the required property.
\end{proof}

\begin{lemma}
\label{lemma-existence-good-dualizing}
In Situation \ref{situation-dualizing} let $X$ be a scheme of finite type
over $S$ and let $\mathcal{U}$ be a finite open covering
of $X$ by schemes separated over $S$. Then there exists
a dualizing complex normalized relative to $\omega_S^\bullet$ and
$\mathcal{U}$.
\end{lemma}

\begin{proof}
Say $\mathcal{U} : X = \bigcup_{i = 1, \ldots, n} U_i$.
We prove the lemma by induction on $n$. The base case $n = 1$ is immediate.
Assume $n > 1$. Set $X' = U_1 \cup \ldots \cup U_{n - 1}$
and let $(K', \{\alpha'_i\}_{i = 1, \ldots, n - 1})$
be a dualizing complex normalized relative to $\omega_S^\bullet$
and $\mathcal{U}' : X' = \bigcup_{i = 1, \ldots, n - 1} U_i$.
It is clear that $(K'|_{X' \cap U_n}, \alpha'_i|_{U_i \cap U_n})$
is a dualizing complex normalized relative to $\omega_S^\bullet$
and the covering
$X' \cap U_n = \bigcup_{i = 1, \ldots, n - 1} U_i \cap U_n$.
On the other hand, by condition (\ref{item-cocycle-glueing}) the pair
$(\omega_n^\bullet|_{X' \cap U_n}, \varphi_{ni})$
is another dualizing complex normalized relative to $\omega_S^\bullet$
and the covering
$X' \cap U_n = \bigcup_{i = 1, \ldots, n - 1} U_i \cap U_n$.
By Lemma \ref{lemma-good-dualizing-unique} we obtain a unique isomorphism
$$
\epsilon : K'|_{X' \cap U_n} \longrightarrow \omega_i^\bullet|_{X' \cap U_n}
$$
compatible with the given local isomorphisms.
By Cohomology, Lemma \ref{cohomology-lemma-glue}
we obtain $K \in D(\mathcal{O}_X)$ together with
isomorphisms $\beta : K|_{X'} \to K'$ and
$\gamma : K|_{U_n} \to \omega_n^\bullet$ such that
$\epsilon = \gamma|_{X'\cap U_n} \circ \beta|_{X' \cap U_n}^{-1}$.
Then we define
$$
\alpha_i = \alpha'_i \circ \beta|_{U_i}, i = 1, \ldots, n - 1,
\text{ and }
\alpha_n = \gamma
$$
We still need to verify that $\varphi_{ij}$ is given by
$\alpha_j|_{U_i \cap U_j} \circ \alpha_i^{-1}|_{U_i \cap U_j}$.
For $i, j \leq n - 1$ this follows from the corresponding
condition for $\alpha_i'$. For $i = j = n$ it is clear as well.
If $i < j = n$, then we get
$$
\alpha_n|_{U_i \cap U_n} \circ \alpha_i^{-1}|_{U_i \cap U_n} =
\gamma|_{U_i \cap U_n} \circ \beta^{-1}|_{U_i \cap U_n}
\circ (\alpha'_i)^{-1}|_{U_i \cap U_n} =
\epsilon|_{U_i \cap U_n} \circ (\alpha'_i)^{-1}|_{U_i \cap U_n}
$$
This is equal to $\alpha_{in}$ exactly because $\epsilon$
is the unique map compatible with the maps
$\alpha_i'$ and $\alpha_{ni}$.
\end{proof}

\noindent
Let $(S, \omega_S^\bullet)$ be as in Situation \ref{situation-dualizing}.
The upshot of the lemmas above is that given any scheme $X$ of finite type
over $S$, there is a pair $(K, \alpha_U)$ given up to unique isomorphism,
consisting of an object $K \in D(\mathcal{O}_X)$ and isomorphisms
$\alpha_U : K|_U \to \omega_U^\bullet$ for every open subscheme
$U \subset X$ which is separated over $S$. Here
$\omega_U^\bullet = (U \to S)^!\omega_S^\bullet$ is a dualizing
complex on $U$, see Section \ref{section-duality}. Moreover, if
$\mathcal{U} : X = \bigcup U_i$ is a finite open covering
by opens which are separated over $S$, then
$(K, \alpha_{U_i})$ is a dualizing complex normalized relative to
$\omega_S^\bullet$ and $\mathcal{U}$.
Namely, uniqueness up to unique isomorphism by
Lemma \ref{lemma-good-dualizing-unique},
existence for one open covering by
Lemma \ref{lemma-existence-good-dualizing}, and
the fact that $K$ then works for all open coverings is
Lemma \ref{lemma-good-dualizing-independence-covering}.

\begin{definition}
\label{definition-good-dualizing}
Let $S$ be a Noetherian scheme and let $\omega_S^\bullet$ be a dualizing
complex on $S$. Let $X$ be a scheme of finite type over $S$.
The complex $K$ constructed above is called the
{\it dualizing complex normalized relative to $\omega_S^\bullet$}
and is denoted $\omega_X^\bullet$.
\end{definition}

\noindent
As the terminology suggest, a dualizing complex normalized relative to
$\omega_S^\bullet$ is not just an object of the derived category of $X$
but comes equipped with the local isomorphisms described above.
This does not conflict with setting
$\omega_X^\bullet = p^!\omega_S^\bullet$ where $p : X \to S$ is the
structure morphism if $X$ is separated over $S$. More generally
we have the following sanity check.

\begin{lemma}
\label{lemma-good-over-both}
Let $(S, \omega_S^\bullet)$ be as in Situation \ref{situation-dualizing}.
Let $f : X \to Y$ be a morphism of finite type schemes over $S$.
Let $\omega_X^\bullet$ and $\omega_Y^\bullet$ be dualizing complexes
normalized relative to $\omega_S^\bullet$. Then $\omega_X^\bullet$
is a dualizing complex normalized relative to $\omega_Y^\bullet$.
\end{lemma}

\begin{proof}
This is just a matter of bookkeeping.
Choose a finite affine open covering $\mathcal{V} : Y = \bigcup V_j$.
For each $j$ choose a finite affine open covering $f^{-1}(V_j) = U_{ji}$.
Set $\mathcal{U} : X = \bigcup U_{ji}$. The schemes $V_j$ and $U_{ji}$ are
separated over $S$, hence we have the upper shriek functors for
$q_j : V_j \to S$, $p_{ji} : U_{ji} \to S$ and
$f_{ji} : U_{ji} \to V_j$ and $f_{ji}' : U_{ji} \to Y$.
Let $(L, \beta_j)$ be a dualizing complex normalized relative to
$\omega_S^\bullet$ and $\mathcal{V}$.
Let $(K, \gamma_{ji})$ be a dualizing complex normalized relative to
$\omega_S^\bullet$ and $\mathcal{U}$.
(In other words, $L = \omega_Y^\bullet$ and $K = \omega_X^\bullet$.)
We can define
$$
\alpha_{ji} :
K|_{U_{ji}} \xrightarrow{\gamma_{ji}}
p_{ji}^!\omega_S^\bullet = f_{ji}^!q_j^!\omega_S^\bullet
\xrightarrow{f_{ji}^!\beta_j^{-1}} f_{ji}^!(L|_{V_j}) =
(f_{ji}')^!(L)
$$
To finish the proof we have to show that
$\alpha_{ji}|_{U_{ji} \cap U_{j'i'}}
\circ \alpha_{j'i'}^{-1}|_{U_{ji} \cap U_{j'i'}}$
is the canonical isomorphism
$(f_{ji}')^!(L)|_{U_{ji} \cap U_{j'i'}} \to
(f_{j'i'}')^!(L)|_{U_{ji} \cap U_{j'i'}}$. This is formal and we
omit the details.
\end{proof}

\begin{lemma}
\label{lemma-open-immersion-good-dualizing-complex}
Let $(S, \omega_S^\bullet)$ be as in Situation \ref{situation-dualizing}.
Let $j : X \to Y$ be an open immersion of schemes of finite type over $S$.
Let $\omega_X^\bullet$ and $\omega_Y^\bullet$ be dualizing complexes
normalized relative to $\omega_S^\bullet$. Then there is a canonical
isomorphism $\omega_X^\bullet = \omega_Y^\bullet|_X$.
\end{lemma}

\begin{proof}
Immediate from the construction of normalized dualizing complexes
given just above
Definition \ref{definition-good-dualizing}.
\end{proof}

\begin{lemma}
\label{lemma-proper-map-good-dualizing-complex}
Let $(S, \omega_S^\bullet)$ be as in Situation \ref{situation-dualizing}.
Let $f : X \to Y$ be a proper morphism of schemes of finite type over $S$.
Let $\omega_X^\bullet$ and $\omega_Y^\bullet$ be dualizing complexes
normalized relative to $\omega_S^\bullet$. Let $a$ be the
right adjoint of Lemma \ref{lemma-twisted-inverse-image} for
$f$. Then there is a canonical isomorphism
$a(\omega_Y^\bullet) = \omega_X^\bullet$.
\end{lemma}

\begin{proof}
Let $p : X \to S$ and $q : Y \to S$ be the structure morphisms.
If $X$ and $Y$ are separated over $S$, then this follows
from the fact that $\omega_X^\bullet = p^!\omega_S^\bullet$,
$\omega_Y^\bullet = q^!\omega_S^\bullet$, $f^! = a$, and
$f^! \circ q^! = p^!$ (Lemma \ref{lemma-upper-shriek-composition}).
In the general case we first use Lemma \ref{lemma-good-over-both}
to reduce to the case $Y = S$. In this case $X$ and $Y$
are separated over $S$ and we've just seen the result.
\end{proof}

\noindent
Let $(S, \omega_S^\bullet)$ be as in Situation \ref{situation-dualizing}.
For a scheme $X$ of finite type over $S$ denote $\omega_X^\bullet$ the
dualizing complex for $X$ normalized relative to $\omega_S^\bullet$.
Define $D_X(-) = R\SheafHom_{\mathcal{O}_X}(-, \omega_X^\bullet)$
as in Lemma \ref{lemma-dualizing-schemes}.
Let $f : X \to Y$ be a morphism of finite type schemes over $S$.
Define
$$
f_{new}^! = D_X \circ Lf^* \circ D_Y :
D_{\textit{Coh}}^+(\mathcal{O}_Y)
\to
D_{\textit{Coh}}^+(\mathcal{O}_X)
$$
If $f : X \to Y$ and $g : Y \to Z$ are composable
morphisms between schemes of finite type over $S$, define
\begin{align*}
(g \circ f)^!_{new} & = D_X \circ L(g \circ f)^* \circ D_Z \\
& = D_X \circ Lf^* \circ Lg^* \circ D_Z \\
& \to D_X \circ Lf^* \circ D_Y \circ D_Y \circ Lg^* \circ D_Z \\
& = f^!_{new} \circ g^!_{new}
\end{align*}
where the arrow is defined in Lemma \ref{lemma-dualizing-schemes}.
We collect the results together in the following lemma.

\begin{lemma}
\label{lemma-duality-bootstrap}
Let $(S, \omega_S^\bullet)$ be as in Situation \ref{situation-dualizing}.
With $f^!_{new}$ and $\omega_X^\bullet$ defined for all (morphisms of)
schemes of finite type over $S$ as above:
\begin{enumerate}
\item the functors $f^!_{new}$ and the arrows
$(g \circ f)^!_{new} \to f^!_{new} \circ g^!_{new}$
turn $D_{\textit{Coh}}^+$ into a pseudo functor from the category of
schemes of finite type over $S$ into the $2$-category of categories,
\item $\omega_X^\bullet = (X \to S)^!_{new} \omega_S^\bullet$,
\item the functor $D_X$
defines an involution of $D_{\textit{Coh}}(\mathcal{O}_X)$
switching $D_{\textit{Coh}}^+(\mathcal{O}_X)$ and
$D_{\textit{Coh}}^-(\mathcal{O}_X)$ and fixing
$D_{\textit{Coh}}^b(\mathcal{O}_X)$,
\item $\omega_X^\bullet = f^!_{new}\omega_Y^\bullet$ for
$f : X \to Y$ a morphism of finite type schemes over $S$,
\item $f^!_{new}M = D_X(Lf^*D_Y(M))$ for
$M \in D_{\textit{Coh}}^+(\mathcal{O}_Y)$, and
\item if in addition $f$ is proper, then $f^!_{new}$ is isomorphic
to the restriction of the right adjoint of
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D_\QCoh(\mathcal{O}_Y)$ to
$D_{\textit{Coh}}^+(\mathcal{O}_Y)$ and there is a canonical isomorphism
$$
Rf_*R\SheafHom_{\mathcal{O}_X}(K, f^!_{new}M)
\to
R\SheafHom_{\mathcal{O}_Y}(Rf_*K, M)
$$
for $K \in D^-_{\textit{Coh}}(\mathcal{O}_X)$ and
$M \in D_{\textit{Coh}}^+(\mathcal{O}_Y)$, and
$$
Rf_*R\SheafHom_{\mathcal{O}_X}(K, \omega_X^\bullet) =
R\SheafHom_{\mathcal{O}_Y}(Rf_*K, \omega_Y^\bullet)
$$
for $K \in D^-_{\textit{Coh}}(\mathcal{O}_X)$ and
\end{enumerate}
If $X$ is separated over $S$, then
$\omega_X^\bullet$ is canonically isomorphic to
$(X \to S)^!\omega_S^\bullet$ and
if $f$ is a morphism between schemes separated
over $S$, then there is a canonical isomorphism\footnote{We haven't
checked that these are compatible with the isomorphisms
$(g \circ f)^! \to f^! \circ g^!$ and
$(g \circ f)^!_{new} \to f^!_{new} \circ g^!_{new}$. We will do this
here if we need this later.}
$f_{new}^!K = f^!K$ for $K$ in $D_{\textit{Coh}}^+$.
\end{lemma}

\begin{proof}
Let $f : X \to Y$, $g : Y \to Z$, $h : Z \to T$ be morphisms of schemes
of finite type over $S$. We have to show that
$$
\xymatrix{
(h \circ g \circ f)^!_{new} \ar[r] \ar[d] &
f^!_{new} \circ (h \circ g)^!_{new} \ar[d] \\
(g \circ f)^!_{new} \circ h^!_{new} \ar[r] &
f^!_{new} \circ g^!_{new} \circ h^!_{new}
}
$$
is commutative. Let $\eta_Y : \text{id} \to D_Y^2$
and $\eta_Z : \text{id} \to D_Z^2$ be the canonical isomorphisms
of Lemma \ref{lemma-dualizing-schemes}. Then, using
Categories, Lemma \ref{categories-lemma-properties-2-cat-cats},
a computation (omitted) shows that both arrows
$(h \circ g \circ f)^!_{new} \to f^!_{new} \circ g^!_{new} \circ h^!_{new}$
are given by
$$
1 \star \eta_Y \star 1 \star \eta_Z \star 1 :
D_X \circ Lf^* \circ Lg^* \circ Lh^* \circ D_T
\longrightarrow
D_X \circ Lf^* \circ D_Y^2 \circ Lg^* \circ D_Z^2 \circ Lh^* \circ D_T
$$
This proves (1). Part (2) is immediate from the definition of
$(X \to S)^!_{new}$ and the fact that $D_S(\omega_S^\bullet) = \mathcal{O}_S$.
Part (3) is Lemma \ref{lemma-dualizing-schemes}.
Part (4) follows by the same argument as part (2).
Part (5) is the definition of $f^!_{new}$.

\medskip\noindent
Proof of (6). Let $a$ be the
right adjoint of Lemma \ref{lemma-twisted-inverse-image} for the
proper morphism $f : X \to Y$ of schemes of finite type over $S$.
The issue is that we do not know $X$ or $Y$ is
separated over $S$ (and in general this won't be true)
hence we cannot immediately apply
Lemma \ref{lemma-shriek-via-duality} to $f$ over $S$.
To get around this we use the canonical identification
$\omega_X^\bullet = a(\omega_Y^\bullet)$ of
Lemma \ref{lemma-proper-map-good-dualizing-complex}.
Hence $f^!_{new}$ is the restriction of $a$ to
$D_{\textit{Coh}}^+(\mathcal{O}_Y)$ by Lemma \ref{lemma-shriek-via-duality}
applied to $f : X \to Y$ over the base scheme $Y$!
The displayed equalities hold by
Example \ref{example-iso-on-RSheafHom-noetherian}.

\medskip\noindent
The final assertions follow from the construction of normalized
dualizing complexes and the already used Lemma \ref{lemma-shriek-via-duality}.
\end{proof}

\begin{remark}
\label{remark-independent-omega-S}
Let $S$ be a Noetherian scheme which has a dualizing complex.
Let $f : X \to Y$ be a morphism of schemes of finite type
over $S$. Then the functor
$$
f_{new}^! : D^+_{Coh}(\mathcal{O}_Y) \to D^+_{Coh}(\mathcal{O}_X)
$$
is independent of the choice of the dualizing complex $\omega_S^\bullet$
up to canonical isomorphism. We sketch the proof. Any second dualizing complex
is of the form $\omega_S^\bullet \otimes_{\mathcal{O}_S}^\mathbf{L} \mathcal{L}$
where $\mathcal{L}$ is an invertible object of $D(\mathcal{O}_S)$, see
Lemma \ref{lemma-dualizing-unique-schemes}.
For any separated morphism $p : U \to S$ of finite type we have
$p^!(\omega_S^\bullet \otimes^\mathbf{L}_{\mathcal{O}_S} \mathcal{L}) =
p^!(\omega_S^\bullet) \otimes^\mathbf{L}_{\mathcal{O}_U} Lp^*\mathcal{L}$
by Lemma \ref{lemma-compare-with-pullback-perfect}.
Hence, if $\omega_X^\bullet$ and $\omega_Y^\bullet$ are the
dualizing complexes normalized relative to $\omega_S^\bullet$ we see that
$\omega_X^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L} La^*\mathcal{L}$ and
$\omega_Y^\bullet \otimes_{\mathcal{O}_Y}^\mathbf{L} Lb^*\mathcal{L}$
are the dualizing complexes normalized relative to
$\omega_S^\bullet \otimes_{\mathcal{O}_S}^\mathbf{L} \mathcal{L}$
(where $a : X \to S$ and $b : Y \to S$ are the structure morphisms).
Then the result follows as
\begin{align*}
& R\SheafHom_{\mathcal{O}_X}(Lf^*R\SheafHom_{\mathcal{O}_Y}(K,
\omega_Y^\bullet \otimes_{\mathcal{O}_Y}^\mathbf{L} Lb^*\mathcal{L}),
\omega_X^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L} La^*\mathcal{L}) \\
& = R\SheafHom_{\mathcal{O}_X}(Lf^*R(\SheafHom_{\mathcal{O}_Y}(K,
\omega_Y^\bullet) \otimes_{\mathcal{O}_Y}^\mathbf{L} Lb^*\mathcal{L}),
\omega_X^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L} La^*\mathcal{L}) \\
& = R\SheafHom_{\mathcal{O}_X}(Lf^*R\SheafHom_{\mathcal{O}_Y}(K,
\omega_Y^\bullet) \otimes_{\mathcal{O}_X}^\mathbf{L} La^*\mathcal{L},
\omega_X^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L} La^*\mathcal{L}) \\
& = R\SheafHom_{\mathcal{O}_X}(Lf^*R\SheafHom_{\mathcal{O}_Y}(K,
\omega_Y^\bullet), \omega_X^\bullet)
\end{align*}
for $K \in D^+_{Coh}(\mathcal{O}_Y)$.
The last equality because $La^*\mathcal{L}$ is invertible in
$D(\mathcal{O}_X)$.
\end{remark}


\begin{example}
\label{example-trace-proper}
Let $S$ be a Noetherian scheme and let $\omega_S^\bullet$ be a
dualizing complex. Let $f : X \to Y$ be a proper morphism of finite
type schemes over $S$. Let $\omega_X^\bullet$ and $\omega_Y^\bullet$
be dualizing complexes normalized relative to $\omega_S^\bullet$.
In this situation we have $a(\omega_Y^\bullet) = \omega_X^\bullet$
(Lemma \ref{lemma-proper-map-good-dualizing-complex})
and hence the trace map (Section \ref{section-trace}) is a canonical arrow
$$
\text{Tr}_f : Rf_*\omega_X^\bullet \longrightarrow \omega_Y^\bullet
$$
which produces the isomorphisms (Lemma \ref{lemma-duality-bootstrap})
$$
\Hom_X(L, \omega_X^\bullet) = \Hom_Y(Rf_*L, \omega_Y^\bullet)
$$
and
$$
Rf_*R\SheafHom_{\mathcal{O}_X}(L, \omega_X^\bullet) =
R\SheafHom_{\mathcal{O}_Y}(Rf_*L, \omega_Y^\bullet)
$$
for $L$ in $D_\QCoh(\mathcal{O}_X)$.
\end{example}

\begin{remark}
\label{remark-dualizing-finite}
Let $S$ be a Noetherian scheme and let $\omega_S^\bullet$ be a dualizing
complex. Let $f : X \to Y$ be a finite morphism between schemes of finite
type over $S$. Let $\omega_X^\bullet$ and $\omega_Y^\bullet$ be
dualizing complexes normalized relative to $\omega_S^\bullet$.
Then we have
$$
f_*\omega_X^\bullet = R\SheafHom(f_*\mathcal{O}_X, \omega_Y^\bullet)
$$
in $D_\QCoh^+(f_*\mathcal{O}_X)$ by Lemmas \ref{lemma-finite-twisted} and
\ref{lemma-proper-map-good-dualizing-complex}
and the trace map of Example \ref{example-trace-proper} is the map
$$
\text{Tr}_f : Rf_*\omega_X^\bullet = f_*\omega_X^\bullet =
R\SheafHom(f_*\mathcal{O}_X, \omega_Y^\bullet) \longrightarrow
\omega_Y^\bullet
$$
which often goes under the name ``evaluation at $1$''.
\end{remark}

\begin{remark}
\label{remark-relative-dualizing-complex-shriek}
Let $f : X \to Y$ be a flat proper morphism of finite type
schemes over a pair $(S, \omega_S^\bullet)$ as in
Situation \ref{situation-dualizing}. The relative dualizing complex
(Remark \ref{remark-relative-dualizing-complex}) is
$\omega_{X/Y}^\bullet = a(\mathcal{O}_Y)$. By
Lemma \ref{lemma-proper-map-good-dualizing-complex}
we have the first canonical isomorphism in
$$
\omega_X^\bullet = a(\omega_Y^\bullet) =
Lf^*\omega_Y^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L} \omega_{X/Y}^\bullet
$$
in $D(\mathcal{O}_X)$. The second canonical isomorphism follows from the
discussion in Remark \ref{remark-relative-dualizing-complex}.
\end{remark}




\section{Dimension functions}
\label{section-dimension-functions}

\noindent
We need a bit more information about how the dimension functions change
when passing to a scheme of finite type over another.

\begin{lemma}
\label{lemma-good-dualizing-normalized}
Let $S$ be a Noetherian scheme and let $\omega_S^\bullet$ be a
dualizing complex. Let $X$ be a scheme of finite type over $S$ and let
$\omega_X^\bullet$ be the dualizing complex normalized relative
to $\omega_S^\bullet$. If $x \in X$ is a closed point lying over
a closed point $s$ of $S$, then $\omega_{X, x}^\bullet$
is a normalized dualizing complex over $\mathcal{O}_{X, x}$
provided that $\omega_{S, s}^\bullet$ is a normalized dualizing
complex over $\mathcal{O}_{S, s}$.
\end{lemma}

\begin{proof}
We may replace $X$ by an affine neighbourhood of $x$, hence we may
and do assume that $f : X \to S$ is separated.
Then $\omega_X^\bullet = f^!\omega_S^\bullet$. We have to show that
$R\Hom_{\mathcal{O}_{X, x}}(\kappa(x), \omega_{X, x}^\bullet)$
is sitting in degree $0$. Let $i_x : x \to X$ denote the inclusion
morphism which is a closed immersion as $x$ is a closed point.
Hence $R\Hom_{\mathcal{O}_{X, x}}(\kappa(x), \omega_{X, x}^\bullet)$
represents $i_x^!\omega_X^\bullet$ by
Lemma \ref{lemma-shriek-closed-immersion}.
Consider the commutative diagram
$$
\xymatrix{
x \ar[r]_{i_x} \ar[d]_\pi & X \ar[d]^f \\
s \ar[r]^{i_s} & S
}
$$
By Morphisms, Lemma
\ref{morphisms-lemma-closed-point-fibre-locally-finite-type}
the extension $\kappa(x)/\kappa(s)$ is finite and hence
$\pi$ is a finite morphism. We conclude that
$$
i_x^!\omega_X^\bullet = i_x^! f^! \omega_S^\bullet =
\pi^! i_s^! \omega_S^\bullet
$$
Thus if $\omega_{S, s}^\bullet$ is a normalized dualizing complex
over $\mathcal{O}_{S, s}$, then $i_s^!\omega_S^\bullet = \kappa(s)[0]$
by the same reasoning as above. We have
$$
R\pi_*(\pi^!(\kappa(s)[0])) =
R\SheafHom_{\mathcal{O}_s}(R\pi_*(\kappa(x)[0]), \kappa(s)[0]) =
\widetilde{\Hom_{\kappa(s)}(\kappa(x), \kappa(s))}
$$
The first equality by Example \ref{example-iso-on-RSheafHom-noetherian}
applied with $L = \kappa(x)[0]$. The second equality holds because
$\pi_*$ is exact.
Thus $\pi^!(\kappa(s)[0])$ is supported in degree $0$ and we win.
\end{proof}

\begin{lemma}
\label{lemma-good-dualizing-dimension-function}
Let $S$ be a Noetherian scheme and let $\omega_S^\bullet$ be a
dualizing complex. Let $f : X \to S$ be of finite type
and let $\omega_X^\bullet$ be the dualizing complex
normalized relative to $\omega_S^\bullet$. For all $x \in X$ we have
$$
\delta_X(x) - \delta_S(f(x)) = \text{trdeg}_{\kappa(f(x))}(\kappa(x))
$$
where $\delta_S$, resp.\ $\delta_X$
is the dimension function of
$\omega_S^\bullet$, resp.\ $\omega_X^\bullet$, see
Lemma \ref{lemma-dimension-function-scheme}.
\end{lemma}

\begin{proof}
We may replace $X$ by an affine neighbourhood of $x$. Hence we may
and do assume there is a compactification $X \subset \overline{X}$
over $S$. Then we may replace $X$ by $\overline{X}$ and assume
that $X$ is proper over $S$. We may also assume $X$ is connected
by replacing $X$ by the connected component of $X$ containing $x$.
Next, recall that both $\delta_X$ and the function
$x \mapsto \delta_S(f(x)) + \text{trdeg}_{\kappa(f(x))}(\kappa(x))$
are dimension functions on $X$, see
Morphisms, Lemma \ref{morphisms-lemma-dimension-function-propagates}
(and the fact that $S$ is universally catenary by
Lemma \ref{lemma-dimension-function-scheme}).
By Topology, Lemma \ref{topology-lemma-dimension-function-unique}
we see that the difference is locally constant, hence constant as $X$ is
connected. Thus it suffices to prove equality in any point of $X$.
By Properties, Lemma \ref{properties-lemma-locally-Noetherian-closed-point}
the scheme $X$ has a closed point $x$. Since $X \to S$ is proper
the image $s$ of $x$ is closed in $S$. Thus we may apply
Lemma \ref{lemma-good-dualizing-normalized} to conclude.
\end{proof}

\begin{lemma}
\label{lemma-shriek}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. Let $x \in X$ with image $y \in Y$. Then
$$
H^i(f^!\mathcal{O}_Y)_x \not = 0
\Rightarrow - \dim_x(X_y) \leq i.
$$
\end{lemma}

\begin{proof}
Since the statement is local on $X$ we may assume $X$
and $Y$ are affine schemes. Write
$X = \Spec(A)$ and $Y = \Spec(R)$.
Then $f^!\mathcal{O}_Y$ corresponds to the relative dualizing
complex $\omega_{A/R}^\bullet$ of
Dualizing Complexes, Section
\ref{dualizing-section-relative-dualizing-complexes-Noetherian}
by Remark \ref{remark-local-calculation-shriek}.
Thus the lemma follows from Dualizing Complexes, Lemma
\ref{dualizing-lemma-relative-dualizing-trivial-vanishing}.
\end{proof}

\begin{lemma}
\label{lemma-flat-shriek}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. Let $x \in X$ with image $y \in Y$.
If $f$ is flat, then
$$
H^i(f^!\mathcal{O}_Y)_x \not = 0
\Rightarrow - \dim_x(X_y) \leq i \leq 0.
$$
In fact, if all fibres of $f$ have dimension $\leq d$, then
$f^!\mathcal{O}_Y$ has tor-amplitude in $[-d, 0]$ as an object
of $D(X, f^{-1}\mathcal{O}_Y)$.
\end{lemma}

\begin{proof}
Arguing exactly as in the proof of Lemma \ref{lemma-shriek}
this follows from Dualizing Complexes, Lemma
\ref{dualizing-lemma-relative-dualizing-flat-vanishing}.
\end{proof}

\begin{lemma}
\label{lemma-shriek-over-CM}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. Let $x \in X$ with image $y \in Y$. Assume
\begin{enumerate}
\item $\mathcal{O}_{Y, y}$ is Cohen-Macaulay, and
\item $\text{trdeg}_{\kappa(f(\xi))}(\kappa(\xi)) \leq r$
for any generic point $\xi$ of an irreducible component
of $X$ containing $x$.
\end{enumerate}
Then
$$
H^i(f^!\mathcal{O}_Y)_x \not = 0
\Rightarrow - r \leq i
$$
and the stalk $H^{-r}(f^!\mathcal{O}_Y)_x$ is $(S_2)$ as an
$\mathcal{O}_{X, x}$-module.
\end{lemma}

\begin{proof}
After replacing $X$ by an open neighbourhood of $x$, we may
assume every irreducible component of $X$ passes through $x$.
Then arguing exactly as in the proof of Lemma \ref{lemma-shriek}
this follows from Dualizing Complexes, Lemma
\ref{dualizing-lemma-relative-dualizing-CM-vanishing}.
\end{proof}

\begin{lemma}
\label{lemma-flat-quasi-finite-shriek}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. If $f$ is flat and quasi-finite, then
$$
f^!\mathcal{O}_Y = \omega_{X/Y}[0]
$$
for some coherent $\mathcal{O}_X$-module $\omega_{X/Y}$ flat over $Y$.
\end{lemma}

\begin{proof}
Consequence of Lemma \ref{lemma-flat-shriek} and the fact that the
cohomology sheaves of $f^!\mathcal{O}_Y$ are coherent by
Lemma \ref{lemma-shriek-coherent}.
\end{proof}

\begin{lemma}
\label{lemma-CM-shriek}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. If $f$ is Cohen-Macaulay (More on Morphisms, Definition
\ref{more-morphisms-definition-CM}), then
$$
f^!\mathcal{O}_Y = \omega_{X/Y}[d]
$$
for some coherent $\mathcal{O}_X$-module $\omega_{X/Y}$ flat over $Y$
where $d$ is the locally constant
function on $X$ which gives the relative dimension of $X$ over $Y$.
\end{lemma}

\begin{proof}
The relative dimension $d$ is well defined and locally constant by
Morphisms, Lemma
\ref{morphisms-lemma-flat-finite-presentation-CM-fibres-relative-dimension}.
The cohomology sheaves of $f^!\mathcal{O}_Y$ are coherent by
Lemma \ref{lemma-shriek-coherent}.
We will get flatness of $\omega_{X/Y}$ from Lemma \ref{lemma-flat-shriek}
if we can show the other cohomology sheaves of $f^!\mathcal{O}_Y$
are zero.

\medskip\noindent
The question is local on $X$, hence we may assume $X$ and $Y$ are affine
and the morphism has relative dimension $d$. If $d = 0$, then the
result follows directly from Lemma \ref{lemma-flat-quasi-finite-shriek}.
If $d > 0$, then we may assume there is a factorization
$$
X \xrightarrow{g} \mathbf{A}^d_Y \xrightarrow{p} Y
$$
with $g$ quasi-finite and flat, see More on Morphisms, Lemma
\ref{more-morphisms-lemma-flat-finite-presentation-characterize-CM}.
Then $f^! = g^! \circ p^!$. By Lemma \ref{lemma-shriek-affine-line}
we see that $p^!\mathcal{O}_Y \cong \mathcal{O}_{\mathbf{A}^d_Y}[-d]$.
We conclude by the case $d = 0$.
\end{proof}

\begin{remark}
\label{remark-the-same-is-true}
Let $S$ be a Noetherian scheme endowed with a dualizing complex
$\omega_S^\bullet$. In this case
Lemmas \ref{lemma-shriek}, \ref{lemma-flat-shriek},
\ref{lemma-flat-quasi-finite-shriek}, and \ref{lemma-CM-shriek}
are true for any morphism $f : X \to Y$ of finite type schemes over $S$
but with $f^!$ replaced by $f_{new}^!$. This is clear because in each
case the proof reduces immediately to the affine case
and then $f^! = f_{new}^!$ by Lemma \ref{lemma-duality-bootstrap}.
\end{remark}




\section{Dualizing modules}
\label{section-dualizing-module}


\noindent
This section is a continuation of
Dualizing Complexes, Section \ref{dualizing-section-dualizing-module}.

\medskip\noindent
Let $X$ be a Noetherian scheme and let $\omega_X^\bullet$ be a
dualizing complex. Let $n \in \mathbf{Z}$ be the smallest integer such that
$H^n(\omega_X^\bullet)$ is nonzero. In other words, $-n$ is the maximal
value of the dimension function associated to $\omega_X^\bullet$
(Lemma \ref{lemma-dimension-function-scheme}).
Sometimes $H^n(\omega_X^\bullet)$
is called a {\it dualizing module} or {\it dualizing sheaf}
for $X$ and then it is often denoted
by $\omega_X$. We will say ``let $\omega_X$ be a dualizing module''
to indicate the above.

\medskip\noindent
Care has to be taken when using dualizing modules $\omega_X$ on Noetherian
schemes $X$:
\begin{enumerate}
\item the integer $n$ may change when passing from $X$ to an open $U$
of $X$ and then it won't be true that $\omega_X|_U = \omega_U$,
\item the dualizing complex isn't unique; the dualizing module
is only unique up to tensoring by an invertible module.
\end{enumerate}
The second problem will often be irrelevant because we will work
with $X$ of finite type over a base change $S$ which is
endowed with a fixed dualizing complex $\omega_S^\bullet$ and
$\omega_X^\bullet$ will be the dualizing complex normalized relative
to $\omega_S^\bullet$.
The first problem will not occur if $X$ is equidimensional, more precisely,
if the dimension function associated to $\omega_X^\bullet$
(Lemma \ref{lemma-dimension-function-scheme})
maps every generic point of $X$ to the same integer.

\begin{example}
\label{example-proper-over-local}
Say $S = \Spec(A)$ with $(A, \mathfrak m, \kappa)$
a local Noetherian ring, and $\omega_S^\bullet$ corresponds to
a normalized dualizing complex $\omega_A^\bullet$. Then if
$f : X \to S$ is proper over $S$ and $\omega_X^\bullet = f^!\omega_S^\bullet$
the coherent sheaf
$$
\omega_X = H^{-\dim(X)}(\omega_X^\bullet)
$$
is a dualizing module and is often called the dualizing module
of $X$ (with $S$ and $\omega_S^\bullet$ being understood). We will
see that this has good properties.
\end{example}

\begin{example}
\label{example-equidimensional-over-field}
Say $X$ is an equidimensional scheme of finite type
over a field $k$. Then it is customary to take
$\omega_X^\bullet$ the dualizing complex normalized relative to $k[0]$
and to refer to
$$
\omega_X = H^{-\dim(X)}(\omega_X^\bullet)
$$
as the dualizing module of $X$. If $X$ is separated over $k$, then
$\omega_X^\bullet = f^!\mathcal{O}_{\Spec(k)}$ where
$f : X \to \Spec(k)$ is the structure morphism by
Lemma \ref{lemma-duality-bootstrap}. If $X$ is proper over $k$, then
this is a special case of Example \ref{example-proper-over-local}.
\end{example}

\begin{lemma}
\label{lemma-dualizing-module}
Let $X$ be a connected Noetherian scheme and let $\omega_X$ be a dualizing
module on $X$. The support of $\omega_X$ is the union of the irreducible
components of maximal dimension with respect to any dimension function
and $\omega_X$ is a coherent $\mathcal{O}_X$-module having property $(S_2)$.
\end{lemma}

\begin{proof}
By our conventions discussed above there exists a dualizing complex
$\omega_X^\bullet$ such that $\omega_X$ is the leftmost nonvanishing
cohomology sheaf. Since $X$ is connected, any two dimension functions
differ by a constant
(Topology, Lemma \ref{topology-lemma-dimension-function-unique}).
Hence we may use the
dimension function associated to $\omega_X^\bullet$
(Lemma \ref{lemma-dimension-function-scheme}).
With these remarks in place, the lemma now
follows from Dualizing Complexes, Lemma
\ref{dualizing-lemma-depth-dualizing-module}
and the definitions (in particular
Cohomology of Schemes, Definition \ref{coherent-definition-depth}).
\end{proof}

\begin{lemma}
\label{lemma-vanishing-good-dualizing}
Let $X/A$ with $\omega_X^\bullet$ and $\omega_X$ be as in
Example \ref{example-proper-over-local}. Then
\begin{enumerate}
\item $H^i(\omega_X^\bullet) \not = 0 \Rightarrow
i \in \{-\dim(X), \ldots, 0\}$,
\item the dimension of the support of $H^i(\omega_X^\bullet)$ is at most $-i$,
\item $\text{Supp}(\omega_X)$ is the union of
the components of dimension $\dim(X)$, and
\item $\omega_X$ has property $(S_2)$.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $\delta_X$ and $\delta_S$ be the dimension functions associated to
$\omega_X^\bullet$ and $\omega_S^\bullet$ as in
Lemma \ref{lemma-good-dualizing-dimension-function}.
As $X$ is proper over $A$, every closed subscheme of $X$ contains
a closed point $x$ which maps to the closed point $s \in S$
and $\delta_X(x) = \delta_S(s) = 0$. Hence
$\delta_X(\xi) = \dim(\overline{\{\xi\}})$ for any point
$\xi \in X$. Hence we can check each of
the statements of the lemma by looking at what happens over
$\Spec(\mathcal{O}_{X, x})$ in which case the result follows
from Dualizing Complexes, Lemmas \ref{dualizing-lemma-sitting-in-degrees} and
\ref{dualizing-lemma-depth-dualizing-module}.
Some details omitted.
The last two statements can also be deduced from
Lemma \ref{lemma-dualizing-module}.
\end{proof}

\begin{lemma}
\label{lemma-dualizing-module-proper-over-A}
Let $X/A$ with dualizing module $\omega_X$ be as in
Example \ref{example-proper-over-local}.
Let $d = \dim(X_s)$ be the dimension
of the closed fibre. If $\dim(X) = d + \dim(A)$, then
the dualizing module $\omega_X$ represents the functor
$$
\mathcal{F} \longmapsto \Hom_A(H^d(X, \mathcal{F}), \omega_A)
$$
on the category of coherent $\mathcal{O}_X$-modules.
\end{lemma}

\begin{proof}
We have
\begin{align*}
\Hom_X(\mathcal{F}, \omega_X)
& =
\Ext^{-\dim(X)}_X(\mathcal{F}, \omega_X^\bullet) \\
& =
\Hom_X(\mathcal{F}[\dim(X)], \omega_X^\bullet) \\
& =
\Hom_X(\mathcal{F}[\dim(X)], f^!(\omega_A^\bullet)) \\
& =
\Hom_S(Rf_*\mathcal{F}[\dim(X)], \omega_A^\bullet) \\
& =
\Hom_A(H^d(X, \mathcal{F}), \omega_A)
\end{align*}
The first equality because $H^i(\omega_X^\bullet) = 0$ for
$i < -\dim(X)$, see Lemma \ref{lemma-vanishing-good-dualizing} and
Derived Categories, Lemma \ref{derived-lemma-negative-exts}.
The second equality is follows from the definition of Ext groups.
The third equality is our choice of $\omega_X^\bullet$.
The fourth equality holds because $f^!$ is the
right adjoint of Lemma \ref{lemma-twisted-inverse-image} for
$f$, see Section \ref{section-duality}.
The final equality holds because $R^if_*\mathcal{F}$ is zero
for $i > d$ (Cohomology of Schemes, Lemma
\ref{coherent-lemma-higher-direct-images-zero-above-dimension-fibre})
and $H^j(\omega_A^\bullet)$ is zero for $j < -\dim(A)$.
\end{proof}








\section{Cohen-Macaulay schemes}
\label{section-CM}

\noindent
This section is the continuation of Dualizing Complexes, Section
\ref{dualizing-section-CM}.
Duality takes a particularly simple form for Cohen-Macaulay schemes.

\begin{lemma}
\label{lemma-dualizing-module-CM-scheme}
Let $X$ be a locally Noetherian scheme with dualizing complex
$\omega_X^\bullet$.
\begin{enumerate}
\item $X$ is Cohen-Macaulay $\Leftrightarrow$ $\omega_X^\bullet$
locally has a unique nonzero cohomology sheaf,
\item $\mathcal{O}_{X, x}$ is Cohen-Macaulay $\Leftrightarrow$
$\omega_{X, x}^\bullet$ has a unique nonzero cohomology,
\item $U = \{x \in X \mid \mathcal{O}_{X, x}\text{ is Cohen-Macaulay}\}$
is open and Cohen-Macaulay.
\end{enumerate}
If $X$ is connected and Cohen-Macaulay, then there is an integer $n$
and a coherent Cohen-Macaulay $\mathcal{O}_X$-module $\omega_X$
such that $\omega_X^\bullet = \omega_X[-n]$.
\end{lemma}

\begin{proof}
By definition and Dualizing Complexes, Lemma
\ref{dualizing-lemma-dualizing-localize} for every $x \in X$
the complex $\omega_{X, x}^\bullet$ is a dualizing complex over
$\mathcal{O}_{X, x}$. By
Dualizing Complexes, Lemma \ref{dualizing-lemma-apply-CM}
we see that (2) holds.

\medskip\noindent
To see (3) assume that $\mathcal{O}_{X, x}$ is Cohen-Macaulay.
Let $n_x$ be the unique integer such that
$H^{n_{x}}(\omega_{X, x}^\bullet)$ is nonzero.
For an affine neighbourhood $V \subset X$
of $x$ we have $\omega_X^\bullet|_V$ is in $D^b_{\textit{Coh}}(\mathcal{O}_V)$
hence there are finitely many nonzero coherent modules
$H^i(\omega_X^\bullet)|_V$. Thus after shrinking $V$ we may assume
only $H^{n_x}$ is nonzero, see
Modules, Lemma \ref{modules-lemma-finite-type-stalk-zero}.
In this way we see that $\mathcal{O}_{X, v}$ is Cohen-Macaulay
for every $v \in V$. This proves that $U$ is open as well
as a Cohen-Macaulay scheme.

\medskip\noindent
Proof of (1). The implication $\Leftarrow$ follows from (2).
The implication $\Rightarrow$ follows from the discussion
in the previous paragraph, where we showed that if $\mathcal{O}_{X, x}$
is Cohen-Macaulay, then in a neighbourhood of $x$ the complex
$\omega_X^\bullet$ has only one nonzero cohomology sheaf.

\medskip\noindent
Assume $X$ is connected and Cohen-Macaulay. The above shows that
the map $x \mapsto n_x$ is locally constant.
Since $X$ is connected it is constant, say equal to $n$.
Setting $\omega_X = H^n(\omega_X^\bullet)$ we see that the lemma
holds because $\omega_X$ is Cohen-Macaulay by
Dualizing Complexes, Lemma \ref{dualizing-lemma-apply-CM}
(and Cohomology of Schemes, Definition
\ref{coherent-definition-Cohen-Macaulay}).
\end{proof}

\begin{lemma}
\label{lemma-has-dualizing-module-CM-scheme}
Let $X$ be a locally Noetherian scheme. If there exists a coherent sheaf
$\omega_X$ such that $\omega_X[0]$ is a dualizing complex on $X$, then
$X$ is a Cohen-Macaulay scheme.
\end{lemma}

\begin{proof}
This follows immediately from
Dualizing Complexes, Lemma \ref{dualizing-lemma-has-dualizing-module-CM}
and our definitions.
\end{proof}

\begin{lemma}
\label{lemma-affine-flat-Noetherian-CM}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism
of $\textit{FTS}_S$. Let $x \in X$. If $f$ is flat, then
the following are equivalent
\begin{enumerate}
\item $f$ is Cohen-Macaulay at $x$,
\item $f^!\mathcal{O}_Y$ has a unique nonzero cohomology sheaf
in a neighbourhood of $x$.
\end{enumerate}
\end{lemma}

\begin{proof}
One direction of the lemma follows from Lemma \ref{lemma-CM-shriek}.
To prove the converse, we may assume $f^!\mathcal{O}_Y$ has a unique
nonzero cohomology sheaf. Let $y = f(x)$. Let $\xi_1, \ldots, \xi_n \in X_y$
be the generic points of the fibre $X_y$ specializing to $x$.
Let $d_1, \ldots, d_n$ be the dimensions of the corresponding
irreducible components of $X_y$. The morphism $f : X \to Y$ is Cohen-Macaulay
at $\eta_i$ by More on Morphisms, Lemma
\ref{more-morphisms-lemma-flat-finite-presentation-CM-open}.
Hence by Lemma \ref{lemma-CM-shriek} we see that
$d_1 = \ldots = d_n$. If $d$ denotes the common value, then $d = \dim_x(X_y)$.
After shrinking $X$ we may assume all fibres have dimension at most $d$
(Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres}).
Then the only nonzero cohomology sheaf $\omega = H^{-d}(f^!\mathcal{O}_Y)$
is flat over $Y$ by Lemma \ref{lemma-flat-shriek}.
Hence, if $h : X_y \to X$ denotes the canonical morphism, then
$Lh^*(f^!\mathcal{O}_Y) = Lh^*(\omega[d]) = (h^*\omega)[d]$
by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-tor-independence-and-tor-amplitude}.
Thus $h^*\omega[d]$ is the dualizing complex of $X_y$ by
Lemma \ref{lemma-relative-dualizing-fibres}.
Hence $X_y$ is Cohen-Macaulay by
Lemma \ref{lemma-dualizing-module-CM-scheme}.
This proves $f$ is Cohen-Macaulay at $x$ as desired.
\end{proof}

\begin{remark}
\label{remark-CM-morphism-compare-dualizing}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism
of $\textit{FTS}_S$. Assume $f$ is a Cohen-Macaulay morphism of
relative dimension $d$. Let $\omega_{X/Y} = H^{-d}(f^!\mathcal{O}_Y)$
be the unique nonzero cohomology sheaf of $f^!\mathcal{O}_Y$, see
Lemma \ref{lemma-CM-shriek}.
Then there is a canonical isomorphism
$$
f^!K = Lf^*K \otimes_{\mathcal{O}_X}^\mathbf{L} \omega_{X/Y}[d]
$$
for $K \in D^+_\QCoh(\mathcal{O}_Y)$, see
Lemma \ref{lemma-perfect-comparison-shriek}. In particular, if
$S$ has a dualizing complex $\omega_S^\bullet$,
$\omega_Y^\bullet = (Y \to S)^!\omega_S^\bullet$, and
$\omega_X^\bullet = (X \to S)^!\omega_S^\bullet$
then we have
$$
\omega_X^\bullet =
Lf^*\omega_Y^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L} \omega_{X/Y}[d]
$$
Thus if further $X$ and $Y$ are connected and Cohen-Macaulay and
if $\omega_Y$ and $\omega_X$ denote the unique nonzero cohomology
sheaves of $\omega_Y^\bullet$ and $\omega_X^\bullet$, then we
have
$$
\omega_X = f^*\omega_Y \otimes_{\mathcal{O}_X} \omega_{X/Y}.
$$
Similar results hold for $X$ and $Y$ arbitrary finite type schemes
over $S$ (i.e., not necessarily separated over $S$)
with dualizing complexes normalized with respect to
$\omega_S^\bullet$ as in Section \ref{section-glue}.
\end{remark}





\section{Gorenstein schemes}
\label{section-gorenstein}

\noindent
This section is the continuation of Dualizing Complexes, Section
\ref{dualizing-section-gorenstein}.

\begin{definition}
\label{definition-gorenstein}
Let $X$ be a scheme. We say $X$ is {\it Gorenstein} if $X$ is
locally Noetherian and $\mathcal{O}_{X, x}$ is Gorenstein for all $x \in X$.
\end{definition}

\noindent
This definition makes sense because a Noetherian ring is said to
be Gorenstein if and only if all of its local rings are Gorenstein,
see Dualizing Complexes, Definition \ref{dualizing-definition-gorenstein}.

\begin{lemma}
\label{lemma-gorenstein-CM}
A Gorenstein scheme is Cohen-Macaulay.
\end{lemma}

\begin{proof}
Looking affine locally this follows from the corresponding
result in algebra, namely
Dualizing Complexes, Lemma \ref{dualizing-lemma-gorenstein-CM}.
\end{proof}

\begin{lemma}
\label{lemma-regular-gorenstein}
A regular scheme is Gorenstein.
\end{lemma}

\begin{proof}
Looking affine locally this follows from the corresponding
result in algebra, namely
Dualizing Complexes, Lemma \ref{dualizing-lemma-regular-gorenstein}.
\end{proof}

\begin{lemma}
\label{lemma-gorenstein}
Let $X$ be a locally Noetherian scheme.
\begin{enumerate}
\item If $X$ has a dualizing complex $\omega_X^\bullet$, then
\begin{enumerate}
\item $X$ is Gorenstein $\Leftrightarrow$ $\omega_X^\bullet$ is an invertible
object of $D(\mathcal{O}_X)$,
\item $\mathcal{O}_{X, x}$ is Gorenstein $\Leftrightarrow$
$\omega_{X, x}^\bullet$ is an invertible object of $D(\mathcal{O}_{X, x})$,
\item $U = \{x \in X \mid \mathcal{O}_{X, x}\text{ is Gorenstein}\}$
is an open Gorenstein subscheme.
\end{enumerate}
\item If $X$ is Gorenstein, then $X$ has a dualizing complex if and
only if $\mathcal{O}_X[0]$ is a dualizing complex.
\end{enumerate}
\end{lemma}

\begin{proof}
Looking affine locally this follows from the corresponding
result in algebra, namely
Dualizing Complexes, Lemma \ref{dualizing-lemma-gorenstein}.
\end{proof}

\begin{lemma}
\label{lemma-gorenstein-lci}
If $f : Y \to X$ is a local complete intersection morphism
with $X$ a Gorenstein scheme, then $Y$ is Gorenstein.
\end{lemma}

\begin{proof}
By More on Morphisms, Lemma \ref{more-morphisms-lemma-affine-lci}
it suffices to prove the corresponding statement about ring maps.
This is Dualizing Complexes, Lemma \ref{dualizing-lemma-gorenstein-lci}.
\end{proof}

\begin{lemma}
\label{lemma-gorenstein-local-syntomic}
The property $\mathcal{P}(S) =$``$S$ is Gorenstein''
is local in the syntomic topology.
\end{lemma}

\begin{proof}
Let $\{S_i \to S\}$ be a syntomic covering. The scheme $S$ is locally
Noetherian if and only if each $S_i$ is Noetherian, see
Descent, Lemma \ref{descent-lemma-Noetherian-local-fppf}.
Thus we may now assume $S$ and $S_i$ are locally Noetherian.
If $S$ is Gorenstein, then
each $S_i$ is Gorenstein by Lemma \ref{lemma-gorenstein-lci}.
Conversely, if each $S_i$ is Gorenstein, then for each point
$s \in S$ we can pick $i$ and $t \in S_i$ mapping to $s$.
Then $\mathcal{O}_{S, s} \to \mathcal{O}_{S_i, t}$
is a flat local ring homomorphism with $\mathcal{O}_{S_i, t}$
Gorenstein. Hence $\mathcal{O}_{S, s}$ is Gorenstein by
Dualizing Complexes, Lemma \ref{dualizing-lemma-flat-under-gorenstein}.
\end{proof}






\section{Gorenstein morphisms}
\label{section-gorenstein-morphisms}

\noindent
This section is one in a series. The corresponding sections for
normal morphisms,
regular morphisms, and
Cohen-Macaulay morphisms
can be found in More on Morphisms, Sections
\ref{more-morphisms-section-normal},
\ref{more-morphisms-section-regular}, and
\ref{more-morphisms-section-CM}.

\medskip\noindent
The following lemma says that it does not make sense to define
geometrically Gorenstein schemes, since these would be the
same as Gorenstein schemes.

\begin{lemma}
\label{lemma-gorenstein-base-change}
Let $X$ be a locally Noetherian scheme over the field $k$.
Let $k'/k$ be a finitely generated field extension.
Let $x \in X$ be a point, and let $x' \in X_{k'}$ be a point lying
over $x$. Then we have
$$
\mathcal{O}_{X, x}\text{ is Gorenstein}
\Leftrightarrow
\mathcal{O}_{X_{k'}, x'}\text{ is Gorenstein}
$$
If $X$ is locally of finite type over $k$, the same holds for any
field extension $k'/k$.
\end{lemma}

\begin{proof}
In both cases the ring map $\mathcal{O}_{X, x} \to \mathcal{O}_{X_{k'}, x'}$
is a faithfully flat local homomorphism of Noetherian local rings.
Thus if $\mathcal{O}_{X_{k'}, x'}$ is Gorenstein, then so is
$\mathcal{O}_{X, x}$ by
Dualizing Complexes, Lemma \ref{dualizing-lemma-flat-under-gorenstein}.
To go up, we use
Dualizing Complexes, Lemma \ref{dualizing-lemma-flat-under-gorenstein} as well.
Thus we have to show that
$$
\mathcal{O}_{X_{k'}, x'}/\mathfrak m_x \mathcal{O}_{X_{k'}, x'} =
\kappa(x) \otimes_k k'
$$
is Gorenstein. Note that in the first case $k \to k'$ is finitely
generated and in the second case $k \to \kappa(x)$ is finitely
generated. Hence this follows as property (A) holds for
Gorenstein, see Dualizing Complexes, Lemma
\ref{dualizing-lemma-formal-fibres-gorenstein}.
\end{proof}

\noindent
The lemma above guarantees that the following is the correct definition
of Gorenstein morphisms.

\begin{definition}
\label{definition-gorenstein-morphism}
Let $f : X \to Y$ be a morphism of schemes.
Assume that all the fibres $X_y$ are locally Noetherian schemes.
\begin{enumerate}
\item Let $x \in X$, and $y = f(x)$. We say that $f$ is
{\it Gorenstein at $x$} if $f$ is flat at $x$, and the
local ring of the scheme $X_y$ at $x$ is Gorenstein.
\item We say $f$ is a {\it Gorenstein morphism} if $f$ is
Gorenstein at every point of $X$.
\end{enumerate}
\end{definition}

\noindent
Here is a translation.

\begin{lemma}
\label{lemma-gorenstein-morphism}
Let $f : X \to Y$ be a morphism of schemes.
Assume all fibres of $f$ are locally Noetherian.
The following are equivalent
\begin{enumerate}
\item $f$ is Gorenstein, and
\item $f$ is flat and its fibres are Gorenstein schemes.
\end{enumerate}
\end{lemma}

\begin{proof}
This follows directly from the definitions.
\end{proof}

\begin{lemma}
\label{lemma-gorenstein-CM-morphism}
A Gorenstein morphism is Cohen-Macaulay.
\end{lemma}

\begin{proof}
Follows from Lemma \ref{lemma-gorenstein-CM} and the definitions.
\end{proof}

\begin{lemma}
\label{lemma-lci-gorenstein}
A syntomic morphism is Gorenstein. Equivalently a flat
local complete intersection morphism is Gorenstein.
\end{lemma}

\begin{proof}
Recall that a syntomic morphism is flat and its fibres
are local complete intersections over fields, see
Morphisms, Lemma \ref{morphisms-lemma-syntomic-flat-fibres}.
Since a local complete intersection over a field is a Gorenstein scheme
by Lemma \ref{lemma-gorenstein-lci} we conclude.
The properties ``syntomic'' and ``flat and local
complete intersection morphism'' are equivalent by
More on Morphisms, Lemma \ref{more-morphisms-lemma-flat-lci}.
\end{proof}

\begin{lemma}
\label{lemma-composition-gorenstein}
Let $f : X \to Y$ and $g : Y \to Z$ be morphisms. Assume that the
fibres $X_y$, $Y_z$ and $X_z$ of $f$, $g$, and $g \circ f$ are
locally Noetherian.
\begin{enumerate}
\item If $f$ is Gorenstein at $x$ and $g$ is Gorenstein
at $f(x)$, then $g \circ f$ is Gorenstein at $x$.
\item If $f$ and $g$ are Gorenstein, then $g \circ f$ is Gorenstein.
\item If $g \circ f$ is Gorenstein at $x$ and $f$ is flat at $x$,
then $f$ is Gorenstein at $x$ and $g$ is Gorenstein at $f(x)$.
\item If $g \circ f$ is Gorenstein and $f$ is flat, then
$f$ is Gorenstein and $g$ is Gorenstein at every point in
the image of $f$.
\end{enumerate}
\end{lemma}

\begin{proof}
After translating into algebra this follows from
Dualizing Complexes, Lemma \ref{dualizing-lemma-flat-under-gorenstein}.
\end{proof}

\begin{lemma}
\label{lemma-flat-morphism-from-gorenstein-scheme}
\begin{slogan}
Gorensteinnes of the total space of a flat fibration implies
same for base and fibres
\end{slogan}
Let $f : X \to Y$ be a flat morphism of locally Noetherian schemes.
If $X$ is Gorenstein, then $f$ is Gorenstein and $\mathcal{O}_{Y, f(x)}$
is Gorenstein for all $x \in X$.
\end{lemma}

\begin{proof}
After translating into algebra this follows from
Dualizing Complexes, Lemma \ref{dualizing-lemma-flat-under-gorenstein}.
\end{proof}

\begin{lemma}
\label{lemma-base-change-gorenstein}
Let $f : X \to Y$ be a morphism of schemes.
Assume that all the fibres $X_y$ are locally Noetherian schemes.
Let $Y' \to Y$ be locally of finite type. Let $f' : X' \to Y'$
be the base change of $f$.
Let $x' \in X'$ be a point with image $x \in X$.
\begin{enumerate}
\item If $f$ is Gorenstein at $x$, then
$f' : X' \to Y'$ is Gorenstein at $x'$.
\item If $f$ is flat at $x$ and $f'$ is Gorenstein at $x'$, then $f$
is Gorenstein at $x$.
\item If $Y' \to Y$ is flat at $f'(x')$ and $f'$ is Gorenstein at
$x'$, then $f$ is Gorenstein at $x$.
\end{enumerate}
\end{lemma}

\begin{proof}
Note that the assumption on $Y' \to Y$ implies that for $y' \in Y'$
mapping to $y \in Y$ the field extension $\kappa(y')/\kappa(y)$
is finitely generated. Hence also all the fibres
$X'_{y'} = (X_y)_{\kappa(y')}$ are locally Noetherian, see
Varieties, Lemma \ref{varieties-lemma-locally-Noetherian-base-change}.
Thus the lemma makes sense. Set $y' = f'(x')$ and $y = f(x)$.
Hence we get the following commutative diagram of local rings
$$
\xymatrix{
\mathcal{O}_{X', x'} & \mathcal{O}_{X, x} \ar[l] \\
\mathcal{O}_{Y', y'} \ar[u] & \mathcal{O}_{Y, y} \ar[l] \ar[u]
}
$$
where the upper left corner is a localization of the tensor product
of the upper right and lower left corners over the lower right corner.

\medskip\noindent
Assume $f$ is Gorenstein at $x$.
The flatness of $\mathcal{O}_{Y, y} \to \mathcal{O}_{X, x}$
implies the flatness of $\mathcal{O}_{Y', y'} \to \mathcal{O}_{X', x'}$, see
Algebra, Lemma \ref{algebra-lemma-base-change-flat-up-down}.
The fact that $\mathcal{O}_{X, x}/\mathfrak m_y\mathcal{O}_{X, x}$
is Gorenstein implies that
$\mathcal{O}_{X', x'}/\mathfrak m_{y'}\mathcal{O}_{X', x'}$
is Gorenstein, see
Lemma \ref{lemma-gorenstein-base-change}. Hence we see that $f'$
is Gorenstein at $x'$.

\medskip\noindent
Assume $f$ is flat at $x$ and $f'$ is Gorenstein at $x'$.
The fact that $\mathcal{O}_{X', x'}/\mathfrak m_{y'}\mathcal{O}_{X', x'}$
is Gorenstein implies that
$\mathcal{O}_{X, x}/\mathfrak m_y\mathcal{O}_{X, x}$
is Gorenstein, see
Lemma \ref{lemma-gorenstein-base-change}. Hence we see that $f$
is Gorenstein at $x$.

\medskip\noindent
Assume $Y' \to Y$ is flat at $y'$ and $f'$ is Gorenstein at
$x'$. The flatness of $\mathcal{O}_{Y', y'} \to \mathcal{O}_{X', x'}$
and $\mathcal{O}_{Y, y} \to \mathcal{O}_{Y', y'}$ implies the flatness
of $\mathcal{O}_{Y, y} \to \mathcal{O}_{X, x}$, see
Algebra, Lemma \ref{algebra-lemma-base-change-flat-up-down}.
The fact that $\mathcal{O}_{X', x'}/\mathfrak m_{y'}\mathcal{O}_{X', x'}$
is Gorenstein implies that
$\mathcal{O}_{X, x}/\mathfrak m_y\mathcal{O}_{X, x}$
is Gorenstein, see
Lemma \ref{lemma-gorenstein-base-change}. Hence we see that $f$
is Gorenstein at $x$.
\end{proof}

\begin{lemma}
\label{lemma-flat-lft-base-change-gorenstein}
Let $f : X \to Y$ be a morphism of schemes which is flat and
locally of finite type. Then formation of the set
$\{x \in X \mid f\text{ is Gorenstein at }x\}$
commutes with arbitrary base change.
\end{lemma}

\begin{proof}
The assumption implies any fibre of $f$ is locally of finite type
over a field and hence locally Noetherian and the same is true for
any base change. Thus the statement makes sense. Looking at
fibres we reduce to the following problem: let $X$ be a scheme
locally of finite type over a field $k$,
let $K/k$ be a field extension, and
let $x_K \in X_K$ be a point with image $x \in X$.
Problem: show that $\mathcal{O}_{X_K, x_K}$ is Gorenstein if and only if
$\mathcal{O}_{X, x}$ is Gorenstein.

\medskip\noindent
The problem can be solved using a bit of algebra as follows.
Choose an affine open $\Spec(A) \subset X$ containing $x$.
Say $x$ corresponds to $\mathfrak p \subset A$.
With $A_K = A \otimes_k K$ we see that $\Spec(A_K) \subset X_K$
contains $x_K$. Say $x_K$ corresponds to $\mathfrak p_K \subset A_K$.
Let $\omega_A^\bullet$ be a dualizing complex for $A$.
By Dualizing Complexes, Lemma
\ref{dualizing-lemma-base-change-dualizing-over-field}
$\omega_A^\bullet \otimes_A A_K$ is a dualizing complex for $A_K$.
Now we are done because
$A_\mathfrak p \to (A_K)_{\mathfrak p_K}$ is a flat local
homomorphism of Noetherian rings and hence
$(\omega_A^\bullet)_\mathfrak p$ is an invertible object
of $D(A_\mathfrak p)$ if and only if
$(\omega_A^\bullet)_\mathfrak p \otimes_{A_\mathfrak p} (A_K)_{\mathfrak p_K}$
is an invertible object of $D((A_K)_{\mathfrak p_K})$.
Some details omitted; hint: look at cohomology modules.
\end{proof}

\begin{lemma}
\label{lemma-affine-flat-Noetherian-gorenstein}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism
of $\textit{FTS}_S$. Let $x \in X$. If $f$ is flat, then
the following are equivalent
\begin{enumerate}
\item $f$ is Gorenstein at $x$,
\item $f^!\mathcal{O}_Y$ is isomorphic to an invertible object
in a neighbourhood of $x$.
\end{enumerate}
In particular, the set of points where $f$ is Gorenstein is
open in $X$.
\end{lemma}

\begin{proof}
Set $\omega^\bullet = f^!\mathcal{O}_Y$. By
Lemma \ref{lemma-relative-dualizing-fibres}
this is a bounded complex with coherent cohomology
sheaves whose derived restriction $Lh^*\omega^\bullet$
to the fibre $X_y$ is a dualizing complex on $X_y$.
Denote $i : x \to X_y$ the inclusion of a point.
Then the following are equivalent
\begin{enumerate}
\item $f$ is Gorenstein at $x$,
\item $\mathcal{O}_{X_y, x}$ is Gorenstein,
\item $Lh^*\omega^\bullet$ is invertible in a neighbourhood of $x$,
\item $Li^* Lh^* \omega^\bullet$ has exactly one nonzero
cohomology of dimension $1$ over $\kappa(x)$,
\item $L(h \circ i)^* \omega^\bullet$ has exactly one nonzero
cohomology of dimension $1$ over $\kappa(x)$,
\item $\omega^\bullet$ is invertible in a neighbourhood of $x$.
\end{enumerate}
The equivalence of (1) and (2) is by definition (as $f$ is flat).
The equivalence of (2) and (3) follows from
Lemma \ref{lemma-gorenstein}.
The equivalence of (3) and (4) follows from
More on Algebra, Lemma
\ref{more-algebra-lemma-lift-bounded-pseudo-coherent-to-perfect}.
The equivalence of (4) and (5) holds because
$Li^* Lh^* = L(h \circ i)^*$.
The equivalence of (5) and (6) holds by
More on Algebra, Lemma
\ref{more-algebra-lemma-lift-bounded-pseudo-coherent-to-perfect}.
Thus the lemma is clear.
\end{proof}

\begin{lemma}
\label{lemma-flat-finite-presentation-characterize-gorenstein}
Let $f : X \to S$ be a morphism of schemes which is flat and locally
of finite presentation. Let $x \in X$ with image $s \in S$.
Set $d = \dim_x(X_s)$. The following are equivalent
\begin{enumerate}
\item $f$ is Gorenstein at $x$,
\item there exists an open neighbourhood $U \subset X$ of $x$
and a locally quasi-finite morphism $U \to \mathbf{A}^d_S$ over $S$
which is Gorenstein at $x$,
\item there exists an open neighbourhood $U \subset X$ of $x$
and a locally quasi-finite Gorenstein morphism $U \to \mathbf{A}^d_S$ over $S$,
\item for any $S$-morphism $g : U \to \mathbf{A}^d_S$
of an open neighbourhood $U \subset X$ of $x$ we have:
$g$ is quasi-finite at $x$ $\Rightarrow$ $g$ is Gorenstein at $x$.
\end{enumerate}
In particular, the set of points where $f$ is Gorenstein is open in $X$.
\end{lemma}

\begin{proof}
Choose affine open $U = \Spec(A) \subset X$ with $x \in U$ and
$V = \Spec(R) \subset S$ with $f(U) \subset V$. Then $R \to A$
is a flat ring map of finite presentation. Let $\mathfrak p \subset A$
be the prime ideal corresponding to $x$. After replacing $A$ by a
principal localization we may assume there exists a quasi-finite map
$R[x_1, \ldots, x_d]  \to A$, see
Algebra, Lemma \ref{algebra-lemma-quasi-finite-over-polynomial-algebra}.
Thus there exists at least one pair $(U, g)$ consisting of an
open neighbourhood $U \subset X$ of $x$ and a locally\footnote{If $S$
is quasi-separated, then $g$ will be quasi-finite.} quasi-finite morphism
$g : U \to \mathbf{A}^d_S$.

\medskip\noindent
Having said this, the lemma translates into the following algebra
problem (translation omitted). Given $R \to A$ flat and of finite
presentation, a prime $\mathfrak p \subset A$ and
$\varphi : R[x_1, \ldots, x_d] \to A$ quasi-finite at $\mathfrak p$
the following are equivalent
\begin{enumerate}
\item[(a)] $\Spec(\varphi)$ is Gorenstein at $\mathfrak p$, and
\item[(b)] $\Spec(A) \to \Spec(R)$ is Gorenstein at $\mathfrak p$.
\item[(c)] $\Spec(A) \to \Spec(R)$ is Gorenstein in an open neighbourhood
of $\mathfrak p$.
\end{enumerate}
In each case $R[x_1, \ldots, x_n] \to A$ is flat at $\mathfrak p$
hence by openness of flatness
(Algebra, Theorem \ref{algebra-theorem-openness-flatness}),
we may assume $R[x_1, \ldots, x_n] \to A$
is flat (replace $A$ by a suitable principal localization).
By Algebra, Lemma \ref{algebra-lemma-flat-finite-presentation-limit-flat}
there exists $R_0 \subset R$ and $R_0[x_1, \ldots, x_n] \to A_0$
such that $R_0$ is of finite type over $\mathbf{Z}$ and
$R_0 \to A_0$ is of finite type and $R_0[x_1, \ldots, x_n] \to A_0$ is flat.
Note that the set of points where a flat finite type morphism
is Gorenstein commutes with base change by
Lemma \ref{lemma-base-change-gorenstein}.
In this way we reduce to the case where $R$ is Noetherian.

\medskip\noindent
Thus we may assume $X$ and $S$ affine and that
we have a factorization of $f$ of the form
$$
X \xrightarrow{g} \mathbf{A}^n_S \xrightarrow{p} S
$$
with $g$ flat and quasi-finite and $S$ Noetherian. Then $X$ and
$\mathbf{A}^n_S$ are separated over $S$ and we have
$$
f^!\mathcal{O}_S = g^!p^!\mathcal{O}_S = g^!\mathcal{O}_{\mathbf{A}^n_S}[n]
$$
by know properties of upper shriek functors
(Lemmas \ref{lemma-upper-shriek-composition} and
\ref{lemma-shriek-affine-line}).
Hence the equivalence of (a), (b), and (c) by
Lemma \ref{lemma-affine-flat-Noetherian-gorenstein}.
\end{proof}

\begin{lemma}
\label{lemma-gorenstein-local-source-and-target}
The property
$\mathcal{P}(f)=$``the fibres of $f$ are locally Noetherian and $f$ is
Gorenstein'' is local in the fppf topology on the target and
local in the syntomic topology on the source.
\end{lemma}

\begin{proof}
We have
$\mathcal{P}(f) =
\mathcal{P}_1(f) \wedge \mathcal{P}_2(f)$
where
$\mathcal{P}_1(f)=$``$f$ is flat'', and
$\mathcal{P}_2(f)=$``the fibres of $f$ are locally Noetherian
and Gorenstein''.
We know that $\mathcal{P}_1$ is
local in the fppf topology on the source and the target, see
Descent, Lemmas \ref{descent-lemma-descending-property-flat} and
\ref{descent-lemma-flat-fpqc-local-source}. Thus we have to deal
with $\mathcal{P}_2$.

\medskip\noindent
Let $f : X \to Y$ be a morphism of schemes.
Let $\{\varphi_i : Y_i \to Y\}_{i \in I}$ be an fppf covering of $Y$.
Denote $f_i : X_i \to Y_i$ the base change of $f$ by $\varphi_i$.
Let $i \in I$ and let $y_i \in Y_i$ be a point.
Set $y = \varphi_i(y_i)$. Note that
$$
X_{i, y_i} = \Spec(\kappa(y_i)) \times_{\Spec(\kappa(y))} X_y.
$$
and that $\kappa(y_i)/\kappa(y)$ is a finitely generated field
extension. Hence if $X_y$ is locally Noetherian, then
$X_{i, y_i}$ is locally Noetherian, see
Varieties, Lemma \ref{varieties-lemma-locally-Noetherian-base-change}.
And if in addition $X_y$ is Gorenstein,
then $X_{i, y_i}$ is Gorenstein, see
Lemma \ref{lemma-gorenstein-base-change}.
Thus $\mathcal{P}_2$ is fppf local on the target.

\medskip\noindent
Let $\{X_i \to X\}$ be a syntomic covering of $X$.
Let $y \in Y$. In this case $\{X_{i, y} \to X_y\}$ is a
syntomic covering of the fibre. Hence the locality of $\mathcal{P}_2$
for the syntomic topology on the source follows from
Lemma \ref{lemma-gorenstein-local-syntomic}.
\end{proof}




\section{More on dualizing complexes}
\label{section-more-dualizing}

\noindent
Some lemmas which don't fit anywhere else very well.

\begin{lemma}
\label{lemma-descent-ascent}
Let $f : X \to Y$ be a morphism of locally Noetherian schemes. Assume
\begin{enumerate}
\item $f$ is syntomic and surjective, or
\item $f$ is a surjective flat local complete intersection morphism, or
\item $f$ is a surjective Gorenstein morphism of finite type.
\end{enumerate}
Then $K \in D_\QCoh(\mathcal{O}_Y)$ is a dualizing complex on $Y$ if and only
if $Lf^*K$ is a dualizing complex on $X$.
\end{lemma}

\begin{proof}
Taking affine opens and using
Derived Categories of Schemes, Lemma \ref{perfect-lemma-affine-compare-bounded}
this translates into
Dualizing Complexes, Lemma \ref{dualizing-lemma-descent-ascent}.
\end{proof}







\section{Duality for proper schemes over fields}
\label{section-duality-proper-over-field}

\noindent
In this section we work out the consequences of the very general
material above on dualizing complexes and duality for proper schemes
over fields.

\begin{lemma}
\label{lemma-duality-proper-over-field}
Let $X$ be a proper scheme over a field $k$. There exists a dualizing complex
$\omega_X^\bullet$ with the following properties
\begin{enumerate}
\item $H^i(\omega_X^\bullet)$ is nonzero only for $i \in [-\dim(X), 0]$,
\item $\omega_X = H^{-\dim(X)}(\omega_X^\bullet)$ is a coherent
$(S_2)$-module whose support is the irreducible components
of dimension $\dim(X)$,
\item the dimension of the support of $H^i(\omega_X^\bullet)$ is at most $-i$,
\item for $x \in X$ closed the module
$H^i(\omega_{X, x}^\bullet) \oplus \ldots \oplus H^0(\omega_{X, x}^\bullet)$
is nonzero if and only if $\text{depth}(\mathcal{O}_{X, x}) \leq -i$,
\item for $K \in D_\QCoh(\mathcal{O}_X)$ there are functorial
isomorphisms\footnote{This property
characterizes $\omega_X^\bullet$ in $D_\QCoh(\mathcal{O}_X)$
up to unique isomorphism by the Yoneda lemma. Since $\omega_X^\bullet$
is in $D^b_{\textit{Coh}}(\mathcal{O}_X)$ in fact it suffices to consider
$K \in D^b_{\textit{Coh}}(\mathcal{O}_X)$.}
$$
\Ext^i_X(K, \omega_X^\bullet) = \Hom_k(H^{-i}(X, K), k)
$$
compatible with shifts and distinguished triangles,
\item there are functorial isomorphisms
$\Hom(\mathcal{F}, \omega_X) = \Hom_k(H^{\dim(X)}(X, \mathcal{F}), k)$
for $\mathcal{F}$ quasi-coherent on $X$, and
\item if $X \to \Spec(k)$ is smooth of relative dimension $d$,
then $\omega_X^\bullet \cong \wedge^d\Omega_{X/k}[d]$ and
$\omega_X \cong \wedge^d\Omega_{X/k}$.
\end{enumerate}
\end{lemma}

\begin{proof}
Denote $f : X \to \Spec(k)$ the structure morphism. Let $a$ be the
right adjoint of pushforward of this morphism, see
Lemma \ref{lemma-twisted-inverse-image}. Consider the relative dualizing
complex
$$
\omega_X^\bullet = a(\mathcal{O}_{\Spec(k)})
$$
Compare with Remark \ref{remark-relative-dualizing-complex}.
Since $f$ is proper we have
$f^!(\mathcal{O}_{\Spec(k)}) = a(\mathcal{O}_{\Spec(k)})$ by
definition, see Section \ref{section-upper-shriek}.
Applying Lemma \ref{lemma-shriek-dualizing} we find that
$\omega_X^\bullet$ is a dualizing complex. Moreover, we see that
$\omega_X^\bullet$ and $\omega_X$ are as in
Example \ref{example-proper-over-local} and as in
Example \ref{example-equidimensional-over-field}.

\medskip\noindent
Parts (1), (2), and (3) follow from
Lemma \ref{lemma-vanishing-good-dualizing}.

\medskip\noindent
For a closed point $x \in X$ we see that $\omega_{X, x}^\bullet$ is a
normalized dualizing complex over $\mathcal{O}_{X, x}$, see
Lemma \ref{lemma-good-dualizing-normalized}.
Part (4) then follows from Dualizing Complexes, Lemma
\ref{dualizing-lemma-depth-in-terms-dualizing-complex}.

\medskip\noindent
Part (5) holds by construction as $a$ is the right adjoint to
$Rf_* : D_\QCoh(\mathcal{O}_X) \to D(\mathcal{O}_{\Spec(k)}) = D(k)$
which we can identify with $K \mapsto R\Gamma(X, K)$. We also use
that the derived category $D(k)$ of $k$-modules is the same as the
category of graded $k$-vector spaces.

\medskip\noindent
Part (6) follows from Lemma \ref{lemma-dualizing-module-proper-over-A}
for coherent $\mathcal{F}$ and in general by unwinding
(5) for $K = \mathcal{F}[0]$ and $i = -\dim(X)$.

\medskip\noindent
Part (7) follows from Lemma \ref{lemma-smooth-proper}.
\end{proof}

\begin{remark}
\label{remark-duality-proper-over-field}
Let $k$, $X$, and $\omega_X^\bullet$
be as in Lemma \ref{lemma-duality-proper-over-field}.
The identity on the complex $\omega_X^\bullet$ corresponds, via
the functorial isomorphism in part (5), to a map
$$
t : H^0(X, \omega_X^\bullet) \longrightarrow k
$$
For an arbitrary $K$ in $D_\QCoh(\mathcal{O}_X)$ the identification
$\Hom(K, \omega_X^\bullet)$ with $H^0(X, K)^\vee$ in part (5)
corresponds to the pairing
$$
\Hom_X(K, \omega_X^\bullet) \times H^0(X, K) \longrightarrow k,\quad
(\alpha, \beta) \longmapsto t(\alpha(\beta))
$$
This follows from the functoriality of the isomorphisms in (5). Similarly
for any $i \in \mathbf{Z}$ we get the pairing
$$
\Ext^i_X(K, \omega_X^\bullet) \times H^{-i}(X, K) \longrightarrow k,\quad
(\alpha, \beta) \longmapsto t(\alpha(\beta))
$$
Here we think of $\alpha$ as a morphism $K[-i] \to \omega_X^\bullet$
and $\beta$ as an element of $H^0(X, K[-i])$ in order to define
$\alpha(\beta)$. Observe that if $K$ is general, then we only know
that this pairing is nondegenerate on one side: the pairing induces an
isomorphism of $\Hom_X(K, \omega_X^\bullet)$,
resp.\ $\Ext^i_X(K, \omega_X^\bullet)$ with the $k$-linear dual of $H^0(X, K)$,
resp.\ $H^{-i}(X, K)$ but in general not vice versa. If $K$
is in $D^b_{\textit{Coh}}(\mathcal{O}_X)$, then
$\Hom_X(K, \omega_X^\bullet)$, $\Ext_X(K, \omega_X^\bullet)$,
$H^0(X, K)$, and $H^i(X, K)$ are finite dimensional $k$-vector spaces (by
Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-coherent-internal-hom} and
\ref{perfect-lemma-direct-image-coherent-bdd-below})
and the pairings are perfect in the usual sense.
\end{remark}

\begin{remark}
\label{remark-coherent-duality-proper-over-field}
We continue the discussion in Remark \ref{remark-duality-proper-over-field}
and we use the same notation $k$, $X$, $\omega_X^\bullet$, and $t$.
If $\mathcal{F}$ is a coherent $\mathcal{O}_X$-module we obtain
perfect pairings
$$
\langle -, - \rangle :
\Ext^i_X(\mathcal{F}, \omega_X^\bullet) \times H^{-i}(X,\mathcal{F})
\longrightarrow k,\quad
(\alpha, \beta) \longmapsto t(\alpha(\beta))
$$
of finite dimensional $k$-vector spaces. These pairings satisfy the
following (obvious) functoriality: if $\varphi : \mathcal{F} \to \mathcal{G}$
is a homomorphism of coherent $\mathcal{O}_X$-modules, then we have
$$
\langle \alpha \circ \varphi, \beta \rangle =
\langle \alpha, \varphi(\beta) \rangle
$$
for $\alpha \in \Ext^i_X(\mathcal{G}, \omega_X^\bullet)$ and
$\beta \in H^{-i}(X, \mathcal{F})$. In other words, the $k$-linear map
$\Ext^i_X(\mathcal{G}, \omega_X^\bullet) \to
\Ext^i_X(\mathcal{F}, \omega_X^\bullet)$ induced by $\varphi$
is, via the pairings, the $k$-linear dual of the $k$-linear map
$H^{-i}(X, \mathcal{F}) \to H^{-i}(X, \mathcal{G})$ induced
by $\varphi$. Formulated in this manner, this still works if
$\varphi$ is a homomorphism of quasi-coherent $\mathcal{O}_X$-modules.
\end{remark}

\begin{lemma}
\label{lemma-duality-proper-over-field-perfect}
Let $k$, $X$, and $\omega_X^\bullet$
be as in Lemma \ref{lemma-duality-proper-over-field}.
Let $t : H^0(X, \omega_X^\bullet) \to k$ be as in
Remark \ref{remark-duality-proper-over-field}.
Let $E \in D(\mathcal{O}_X)$ be perfect. Then the pairings
$$
H^i(X, \omega_X^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L} E^\vee)
\times
H^{-i}(X, E) \longrightarrow k, \quad
(\xi, \eta) \longmapsto
t((1_{\omega_X^\bullet} \otimes \epsilon)(\xi \cup \eta))
$$
are perfect for all $i$. Here $\cup$ denotes the cup product
of Cohomology, Section \ref{cohomology-section-cup-product} and
$\epsilon : E^\vee \otimes_{\mathcal{O}_X}^\mathbf{L} E \to \mathcal{O}_X$
is as in Cohomology, Example \ref{cohomology-example-dual-derived}.
\end{lemma}

\begin{proof}
By replacing $E$ with $E[-i]$ this reduces to the case $i = 0$.
By Cohomology, Lemma \ref{cohomology-lemma-ext-composition-is-cup}
we see that the pairing is the same as the one discussed
in Remark \ref{remark-duality-proper-over-field}
whence the result by the discussion in that remark.
\end{proof}

\begin{lemma}
\label{lemma-duality-proper-over-field-CM}
Let $X$ be a proper scheme over a field $k$ which is Cohen-Macaulay
and equidimensional of dimension $d$. The module $\omega_X$
of Lemma \ref{lemma-duality-proper-over-field} has the following properties
\begin{enumerate}
\item $\omega_X$ is a dualizing module on $X$
(Section \ref{section-dualizing-module}),
\item $\omega_X$ is a coherent Cohen-Macaulay module whose support is $X$,
\item there are functorial isomorphisms
$\Ext^i_X(K, \omega_X[d]) = \Hom_k(H^{-i}(X, K), k)$
compatible with shifts and distinguished triangles for $K \in D_\QCoh(X)$,
\item there are functorial isomorphisms
$\Ext^{d - i}(\mathcal{F}, \omega_X) = \Hom_k(H^i(X, \mathcal{F}), k)$
for $\mathcal{F}$ quasi-coherent on $X$.
\end{enumerate}
\end{lemma}

\begin{proof}
It is clear from Lemma \ref{lemma-duality-proper-over-field}
that $\omega_X$ is a dualizing module (as it is the left most
nonvanishing cohomology sheaf of a dualizing complex).
We have $\omega_X^\bullet = \omega_X[d]$ and $\omega_X$ is Cohen-Macaulay
as $X$ is Cohen-Macualay, see Lemma \ref{lemma-dualizing-module-CM-scheme}.
The other statements follow from this combined with the
corresponding statements of Lemma \ref{lemma-duality-proper-over-field}.
\end{proof}

\begin{remark}
\label{remark-rework-duality-locally-free-CM}
Let $X$ be a proper Cohen-Macaulay scheme over a field $k$
which is equidimensional of dimension $d$.
Let $\omega_X^\bullet$ and $\omega_X$ be as in
Lemma \ref{lemma-duality-proper-over-field}.
By Lemma \ref{lemma-duality-proper-over-field-CM}
we have $\omega_X^\bullet = \omega_X[d]$.
Let $t : H^d(X, \omega_X) \to k$ be the map of
Remark \ref{remark-duality-proper-over-field}.
Let $\mathcal{E}$ be a finite locally free $\mathcal{O}_X$-module
with dual $\mathcal{E}^\vee$. Then we have perfect pairings
$$
H^i(X, \omega_X \otimes_{\mathcal{O}_X} \mathcal{E}^\vee)
\times
H^{d - i}(X, \mathcal{E})
\longrightarrow
k,\quad
(\xi, \eta) \longmapsto t(1 \otimes \epsilon)(\xi \cup \eta))
$$
where $\cup$ is the cup-product and
$\epsilon : \mathcal{E}^\vee \otimes_{\mathcal{O}_X} \mathcal{E}
\to \mathcal{O}_X$ is the evaluation map.
This is a special case of Lemma \ref{lemma-duality-proper-over-field-perfect}.
\end{remark}

\noindent
Here is a sanity check for the dualizing complex.

\begin{lemma}
\label{lemma-sanity-check-duality}
Let $X$ be a proper scheme over a field $k$. Let $\omega_X^\bullet$ and
$\omega_X$ be as in Lemma \ref{lemma-duality-proper-over-field}.
\begin{enumerate}
\item If $X \to \Spec(k)$ factors as $X \to \Spec(k') \to \Spec(k)$
for some field $k'$, then $\omega_X^\bullet$ and $\omega_X$
are as in Lemma \ref{lemma-duality-proper-over-field} for the morphism
$X \to \Spec(k')$.
\item If $K/k$ is a field extension, then the pullback of
$\omega_X^\bullet$ and $\omega_X$ to the base change $X_K$
are as in  Lemma \ref{lemma-duality-proper-over-field} for the morphism
$X_K \to \Spec(K)$.
\end{enumerate}
\end{lemma}

\begin{proof}
Denote $f : X \to \Spec(k)$ the structure morphism and denote
$f' : X \to \Spec(k')$ the given factorization.
In the proof of Lemma \ref{lemma-duality-proper-over-field}
we took $\omega_X^\bullet = a(\mathcal{O}_{\Spec(k)})$
where $a$ be is the right adjoint of
Lemma \ref{lemma-twisted-inverse-image} for $f$.
Thus we have to show
$a(\mathcal{O}_{\Spec(k)}) \cong a'(\mathcal{O}_{\Spec(k)})$
where $a'$ be is the right adjoint of
Lemma \ref{lemma-twisted-inverse-image} for $f'$.
Since $k' \subset H^0(X, \mathcal{O}_X)$ we see that $k'/k$ is a finite
extension (Cohomology of Schemes, Lemma
\ref{coherent-lemma-proper-over-affine-cohomology-finite}).
By uniqueness of adjoints we have $a = a' \circ b$ where
$b$ is the right adjoint of Lemma
\ref{lemma-twisted-inverse-image} for $g : \Spec(k') \to \Spec(k)$.
Another way to say this: we have $f^! = (f')^! \circ g^!$.
Thus it suffices to show that $\Hom_k(k', k) \cong k'$ as
$k'$-modules, see Example \ref{example-affine-twisted-inverse-image}.
This holds because these are $k'$-vector spaces of
the same dimension (namely dimension $1$).

\medskip\noindent
Proof of (2). This holds because we have base change for $a$ by
Lemma \ref{lemma-more-base-change}. See discussion in
Remark \ref{remark-relative-dualizing-complex}.
\end{proof}








\section{Relative dualizing complexes}
\label{section-relative-dualizing-complexes}

\noindent
For a proper, flat morphism of finite presentation we have a
rigid relative dualizing complex, see
Remark \ref{remark-relative-dualizing-complex} and
Lemma \ref{lemma-van-den-bergh}. For a separated and finite type
morphism $f : X \to Y$ of Noetherian schemes, we can consider
$f^!\mathcal{O}_Y$. In this section we define relative dualizing complexes
for morphisms which are flat and locally of finite presentation
(but not necessarily quasi-separated or quasi-compact) between
schemes (not necessarily locally Noetherian).
We show such complexes exist, are unique up to unique
isomorphism, and agree with the cases mentioned above.
Before reading this section, please read
Dualizing Complexes, Section
\ref{dualizing-section-relative-dualizing-complexes}.

\begin{definition}
\label{definition-relative-dualizing-complex}
Let $X \to S$ be a morphism of schemes which is flat and
locally of finite presentation. Let $W \subset X \times_S X$
be any open such that the diagonal $\Delta_{X/S} : X \to X \times_S X$
factors through a closed immersion $\Delta : X \to W$.
A {\it relative dualizing complex} is a
pair $(K, \xi)$ consisting of an object $K \in D(\mathcal{O}_X)$
and a map
$$
\xi : \Delta_*\mathcal{O}_X \longrightarrow L\text{pr}_1^*K|_W
$$
in $D(\mathcal{O}_W)$ such that
\begin{enumerate}
\item $K$ is $S$-perfect (Derived Categories of Schemes, Definition
\ref{perfect-definition-relatively-perfect}), and
\item $\xi$ defines an isomorphism of $\Delta_*\mathcal{O}_X$
with
$R\SheafHom_{\mathcal{O}_W}(
\Delta_*\mathcal{O}_X, L\text{pr}_1^*K|_W)$.
\end{enumerate}
\end{definition}

\noindent
By Lemma \ref{lemma-sheaf-with-exact-support-ext} condition (2)
is equivalent to the existence of an isomorphism
$$
\mathcal{O}_X \longrightarrow
R\SheafHom(\mathcal{O}_X, L\text{pr}_1^*K|_W)
$$
in $D(\mathcal{O}_X)$ whose pushforward via $\Delta$ is equal to $\xi$.
Since $R\SheafHom(\mathcal{O}_X, L\text{pr}_1^*K|_W)$ is independent
of the choice of the open $W$, so is the category of pairs $(K, \xi)$.
If $X \to S$ is separated, then we can choose $W = X \times_S X$.
We will reduce many of the arguments to the case of rings
using the following lemma.

\begin{lemma}
\label{lemma-relative-dualizing-complex-algebra}
Let $X \to S$ be a morphism of schemes which is flat and
locally of finite presentation. Let $(K, \xi)$ be a relative
dualizing complex. Then for any commutative diagram
$$
\xymatrix{
\Spec(A) \ar[d] \ar[r] & X \ar[d] \\
\Spec(R) \ar[r] & S
}
$$
whose horizontal arrows are open immersions, the
restriction of $K$ to $\Spec(A)$ corresponds via
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-compare-bounded}
to a relative dualizing complex for $R \to A$
in the sense of Dualizing Complexes, Definition
\ref{dualizing-definition-relative-dualizing-complex}.
\end{lemma}

\begin{proof}
Since formation of $R\SheafHom$ commutes with restrictions to
opens we may as well assume $X = \Spec(A)$ and $S = \Spec(R)$.
Observe that relatively perfect objects of $D(\mathcal{O}_X)$
are pseudo-coherent and hence are in $D_\QCoh(\mathcal{O}_X)$
(Derived Categories of Schemes, Lemma \ref{perfect-lemma-pseudo-coherent}).
Thus the statement makes sense.
Observe that taking $\Delta_*$, $L\text{pr}_1^*$, and
$R\SheafHom$ is compatible with what happens on the algebraic
side by
Derived Categories of Schemes,
Lemmas \ref{perfect-lemma-quasi-coherence-pushforward},
\ref{perfect-lemma-quasi-coherence-pullback},
\ref{perfect-lemma-quasi-coherence-internal-hom}.
For the last one we observe that $L\text{pr}_1^*K$
is $S$-perfect (hence bounded below) and that $\Delta_*\mathcal{O}_X$
is a pseudo-coherent object of $D(\mathcal{O}_W)$;
translated into algebra this means that $A$ is pseudo-coherent
as an $A \otimes_R A$-module which follows from
More on Algebra, Lemma
\ref{more-algebra-lemma-more-relative-pseudo-coherent-is-moot}
applied to $R \to A \otimes_R A \to A$.
Thus we recover exactly the conditions in
Dualizing Complexes, Definition
\ref{dualizing-definition-relative-dualizing-complex}.
\end{proof}

\begin{lemma}
\label{lemma-relative-dualizing-RHom}
Let $X \to S$ be a morphism of schemes which is flat and
locally of finite presentation. Let $(K, \xi)$ be a relative
dualizing complex. Then
$\mathcal{O}_X \to R\SheafHom_{\mathcal{O}_X}(K, K)$
is an isomorphism.
\end{lemma}

\begin{proof}
Looking affine locally this reduces using
Lemma \ref{lemma-relative-dualizing-complex-algebra}
to the algebraic case which is
Dualizing Complexes, Lemma \ref{dualizing-lemma-relative-dualizing-RHom}.
\end{proof}

\begin{lemma}
\label{lemma-uniqueness-relative-dualizing}
Let $X \to S$ be a morphism of schemes which is flat and
locally of finite presentation. If $(K, \xi)$ and $(L, \eta)$
are two relative dualizing complexes on $X/S$, then there is a unique
isomorphism $K \to L$ sending $\xi$ to $\eta$.
\end{lemma}

\begin{proof}
Let $U \subset X$ be an affine open mapping into an
affine open of $S$. Then there is an isomorphism
$K|_U \to L|_U$ by Lemma \ref{lemma-relative-dualizing-complex-algebra} and
Dualizing Complexes, Lemma
\ref{dualizing-lemma-uniqueness-relative-dualizing}.
The reader can reuse the argument of that lemma
in the schemes case to obtain a proof in this case.
We will instead use a glueing argument.

\medskip\noindent
Suppose we have an isomorphism $\alpha : K \to L$.
Then $\alpha(\xi) = u \eta$ for some invertible section
$u \in H^0(W, \Delta_*\mathcal{O}_X) = H^0(X, \mathcal{O}_X)$.
(Because both $\eta$ and $\alpha(\xi)$ are generators
of an invertible $\Delta_*\mathcal{O}_X$-module by assumption.)
Hence after replacing $\alpha$ by $u^{-1}\alpha$
we see that $\alpha(\xi) = \eta$.
Since the automorphism group of
$K$ is $H^0(X, \mathcal{O}_X^*)$ by Lemma \ref{lemma-relative-dualizing-RHom}
there is at most one such $\alpha$.

\medskip\noindent
Let $\mathcal{B}$ be the collection of affine opens of
$X$ which map into an affine open of $S$. For each $U \in \mathcal{B}$
we have a unique isomorphism $\alpha_U : K|_U \to L|_U$
mapping $\xi$ to $\eta$ by the discussion in the previous
two paragraphs.
Observe that $\text{Ext}^i(K|_U, K|_U) = 0$ for $i < 0$
and any open $U$ of $X$ by Lemma \ref{lemma-relative-dualizing-RHom}.
By Cohomology, Lemma \ref{cohomology-lemma-vanishing-and-glueing}
applied to $\text{id} : X \to X$ we get a unique morphism
$\alpha : K \to L$ agreeing
with $\alpha_U$ for all $U \in \mathcal{B}$.
Then $\alpha$ sends $\xi$ to $\eta$ as this is true locally.
\end{proof}

\begin{lemma}
\label{lemma-existence-relative-dualizing}
Let $X \to S$ be a morphism of schemes which is
flat and locally of finite presentation.
There exists a relative dualizing complex $(K, \xi)$.
\end{lemma}

\begin{proof}
Let $\mathcal{B}$ be the collection of affine opens of
$X$ which map into an affine open of $S$. For each $U$
we have a relative dualizing complex $(K_U, \xi_U)$ for
$U$ over $S$. Namely, choose an affine open
$V \subset S$ such that $U \to X \to S$ factors through $V$.
Write $U = \Spec(A)$ and $V = \Spec(R)$. By
Dualizing Complexes, Lemma \ref{dualizing-lemma-base-change-relative-dualizing}
there exists a relative dualizing complex $K_A \in D(A)$
for $R \to A$. Arguing backwards through the proof of
Lemma \ref{lemma-relative-dualizing-complex-algebra}
this determines an $V$-perfect object $K_U \in D(\mathcal{O}_U)$
and a map
$$
\xi : \Delta_*\mathcal{O}_U \to L\text{pr}_1^*K_U
$$
in $D(\mathcal{O}_{U \times_V U})$. Since being $V$-perfect is the
same as being $S$-perfect and since $U \times_V U = U \times_S U$
we find that $(K_U, \xi_U)$ is as desired.

\medskip\noindent
If $U' \subset U \subset X$ with $U', U \in \mathcal{B}$, then
we have a unique isomorphism $\rho_{U'}^U : K_U|_{U'} \to K_{U'}$
in $D(\mathcal{O}_{U'})$ sending $\xi_U|_{U' \times_S U'}$
to $\xi_{U'}$ by Lemma \ref{lemma-uniqueness-relative-dualizing}
(note that trivially the restriction of a relative dualizing
complex to an open is a relative dualizing complex).
The uniqueness guarantees that
$\rho^U_{U''} = \rho^V_{U''} \circ \rho ^U_{U'}|_{U''}$
for $U'' \subset U' \subset U$ in $\mathcal{B}$.
Observe that $\text{Ext}^i(K_U, K_U) = 0$ for $i < 0$
for $U \in \mathcal{B}$ by Lemma \ref{lemma-relative-dualizing-RHom}
applied to $U/S$ and $K_U$.
Thus the BBD glueing lemma
(Cohomology, Theorem \ref{cohomology-theorem-glueing-bbd-general})
tells us there is a unique solution, namely, an object
$K \in D(\mathcal{O}_X)$ and isomorphisms $\rho_U : K|_U \to K_U$
such that we have
$\rho^U_{U'} \circ \rho_U|_{U'} = \rho_{U'}$ for all $U' \subset U$,
$U, U' \in \mathcal{B}$.

\medskip\noindent
To finish the proof we have to construct the map
$$
\xi : \Delta_*\mathcal{O}_X \longrightarrow L\text{pr}_1^*K|_W
$$
in $D(\mathcal{O}_W)$ inducing an isomorphism from $\Delta_*\mathcal{O}_X$ to
$R\SheafHom_{\mathcal{O}_W}(\Delta_*\mathcal{O}_X, L\text{pr}_1^*K|_W)$.
Since we may change $W$, we choose
$W = \bigcup_{U \in \mathcal{B}} U \times_S U$.
We can use $\rho_U$ to get isomorphisms
$$
R\SheafHom_{\mathcal{O}_W}(
\Delta_*\mathcal{O}_X, L\text{pr}_1^*K|_W)|_{U \times_S U}
\xrightarrow{\rho_U}
R\SheafHom_{\mathcal{O}_{U \times_S U}}(
\Delta_*\mathcal{O}_U, L\text{pr}_1^*K_U)
$$
As $W$ is covered by the opens $U \times_S U$
we conclude that the cohomology sheaves of
$R\SheafHom_{\mathcal{O}_W}(\Delta_*\mathcal{O}_X, L\text{pr}_1^*K|_W)$
are zero except in degree $0$. Moreover, we obtain isomorphisms
$$
H^0\left(U \times_S U, R\SheafHom_{\mathcal{O}_W}(\Delta_*\mathcal{O}_X,
L\text{pr}_1^*K|_W)\right)
\xrightarrow{\rho_U}
H^0\left((R\SheafHom_{\mathcal{O}_{U \times_S U}}(
\Delta_*\mathcal{O}_U, L\text{pr}_1^*K_U)\right)
$$
Let $\tau_U$ in the LHS be an element mapping to $\xi_U$ under this map.
The compatibilities between
$\rho^U_{U'}$, $\xi_U$, $\xi_{U'}$, $\rho_U$, and $\rho_{U'}$
for $U' \subset U \subset X$ open $U', U \in \mathcal{B}$
imply that $\tau_U|_{U' \times_S U'} = \tau_{U'}$.
Thus we get a global section $\tau$ of the $0$th cohomology sheaf
$H^0(R\SheafHom_{\mathcal{O}_W}(\Delta_*\mathcal{O}_X, L\text{pr}_1^*K|_W))$.
Since the other cohomology sheaves of
$R\SheafHom_{\mathcal{O}_W}(\Delta_*\mathcal{O}_X, L\text{pr}_1^*K|_W)$
are zero, this global section $\tau$
determines a morphism $\xi$ as desired. Since the restriction
of $\xi$ to $U \times_S U$ gives $\xi_U$, we see that it
satisfies the final condition of
Definition \ref{definition-relative-dualizing-complex}.
\end{proof}

\begin{lemma}
\label{lemma-base-change-relative-dualizing}
Consider a cartesian square
$$
\xymatrix{
X' \ar[d]_{f'} \ar[r]_{g'} & X \ar[d]^f \\
S' \ar[r]^g & S
}
$$
of schemes. Assume $X \to S$ is flat and locally of finite presentation.
Let $(K, \xi)$ be a relative dualizing complex for $f$.
Set $K' = L(g')^*K$. Let $\xi'$ be the derived base change of $\xi$
(see proof). Then $(K', \xi')$ is a relative dualizing complex for $f'$.
\end{lemma}

\begin{proof}
Consider the cartesian square
$$
\xymatrix{
X' \ar[d]_{\Delta_{X'/S'}} \ar[r] & X \ar[d]^{\Delta_{X/S}} \\
X' \times_{S'} X' \ar[r]^{g' \times g'} & X \times_S X
}
$$
Choose $W \subset X \times_S X$ open such that $\Delta_{X/S}$
factors through a closed immersion $\Delta : X \to W$.
Choose $W' \subset X' \times_{S'} X'$ open such that $\Delta_{X'/S'}$
factors through a closed immersion $\Delta' : X \to W'$
and such that $(g' \times g')(W') \subset W$. Let us still denote
$g' \times g' : W' \to W$ the induced morphism. We have
$$
L(g' \times g')^*\Delta_*\mathcal{O}_X =
\Delta'_*\mathcal{O}_{X'}
\quad\text{and}\quad
L(g' \times g')^*L\text{pr}_1^*K|_W =
L\text{pr}_1^*K'|_{W'}
$$
The first equality holds because $X$ and $X' \times_{S'} X'$
are tor independent over $X \times_S X$ (see for example
More on Morphisms, Lemma \ref{more-morphisms-lemma-case-of-tor-independence}).
The second holds by transitivity of derived pullback
(Cohomology, Lemma \ref{cohomology-lemma-derived-pullback-composition}).
Thus $\xi' = L(g' \times g')^*\xi$ can be viewed as a map
$$
\xi' : \Delta'_*\mathcal{O}_{X'} \longrightarrow L\text{pr}_1^*K'|_{W'}
$$
Having said this the proof of the lemma is straightforward.
First, $K'$ is $S'$-perfect by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-base-change-relatively-perfect}.
To check that $\xi'$ induces an isomorphism
of $\Delta'_*\mathcal{O}_{X'}$ to
$R\SheafHom_{\mathcal{O}_{W'}}(
\Delta'_*\mathcal{O}_{X'}, L\text{pr}_1^*K'|_{W'})$
we may work affine locally. By
Lemma \ref{lemma-relative-dualizing-complex-algebra}
we reduce to the corresponding statement in algebra
which is proven in Dualizing Complexes, Lemma
\ref{dualizing-lemma-base-change-relative-dualizing}.
\end{proof}

\begin{lemma}
\label{lemma-flat-proper-relative-dualizing}
Let $S$ be a quasi-compact and quasi-separated scheme.
Let $f : X \to S$ be a proper, flat morphism of finite presentation.
The relative dualizing complex $\omega_{X/S}^\bullet$ of
Remark \ref{remark-relative-dualizing-complex}
together with (\ref{equation-pre-rigid}) is a relative
dualizing complex in the sense of
Definition \ref{definition-relative-dualizing-complex}.
\end{lemma}

\begin{proof}
In Lemma \ref{lemma-properties-relative-dualizing} we proved that
$\omega_{X/S}^\bullet$ is $S$-perfect.
Let $c$ be the right adjoint of
Lemma \ref{lemma-twisted-inverse-image}
for the diagonal $\Delta : X \to X \times_S X$.
Then we can apply $\Delta_*$ to (\ref{equation-pre-rigid})
to get an isomorphism
$$
\Delta_*\mathcal{O}_X \to
\Delta_*(c(L\text{pr}_1^*\omega_{X/S}^\bullet)) =
R\SheafHom_{\mathcal{O}_{X \times_S X}}(
\Delta_*\mathcal{O}_X, L\text{pr}_1^*\omega_{X/S}^\bullet)
$$
The equality holds by
Lemmas \ref{lemma-twisted-inverse-image-closed} and
\ref{lemma-sheaf-with-exact-support-ext}.
This finishes the proof.
\end{proof}

\begin{remark}
\label{remark-relative-dualizing-complex-bis}
Let $X \to S$ be a morphism of schemes which is flat, proper, and
of finite presentation. By Lemma \ref{lemma-existence-relative-dualizing}
there exists a relative dualizing complex $(\omega_{X/S}^\bullet, \xi)$
in the sense of Definition \ref{definition-relative-dualizing-complex}.
Consider any morphism $g : S' \to S$ where $S'$ is quasi-compact and
quasi-separated (for example an affine open of $S$).
By Lemma \ref{lemma-base-change-relative-dualizing}
we see that $(L(g')^*\omega_{X/S}^\bullet, L(g')^*\xi)$ is
a relative dualizing complex for the base change $f' : X' \to S'$
in the sense of Definition \ref{definition-relative-dualizing-complex}.
Let $\omega_{X'/S'}^\bullet$ be the relative dualizing complex
for $X' \to S'$ in the sense of Remark \ref{remark-relative-dualizing-complex}.
Combining Lemmas \ref{lemma-flat-proper-relative-dualizing} and
\ref{lemma-uniqueness-relative-dualizing}
we see that there is a unique isomorphism
$$
\omega_{X'/S'}^\bullet \longrightarrow L(g')^*\omega_{X/S}^\bullet
$$
compatible with (\ref{equation-pre-rigid}) and $L(g')^*\xi$.
These isomorphisms are compatible with morphisms between
quasi-compact and quasi-separated schemes over $S$
and the base change isomorphisms of Lemma \ref{lemma-proper-flat-base-change}
(if we ever need this compatibility we will carefully state and prove
it here).
\end{remark}

\begin{lemma}
\label{lemma-compactifyable-relative-dualizing}
In Situation \ref{situation-shriek} let $f : X \to Y$
be a morphism of $\textit{FTS}_S$. If $f$ is flat, then
$f^!\mathcal{O}_Y$ is (the first component of)
a relative dualizing complex for $X$ over $Y$ in the sense of
Definition \ref{definition-relative-dualizing-complex}.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-flat-shriek-relatively-perfect}
we have that $f^!\mathcal{O}_Y$
is $Y$-perfect. As $f$ is separated the diagonal
$\Delta : X \to X \times_Y X$ is a closed immersion and
$\Delta_*\Delta^!(-) =
R\SheafHom_{\mathcal{O}_{X \times_Y X}}(\mathcal{O}_X, -)$, see
Lemmas
\ref{lemma-twisted-inverse-image-closed} and
\ref{lemma-sheaf-with-exact-support-ext}.
Hence to finish the proof it suffices to show
$\Delta^!(L\text{pr}_1^*f^!(\mathcal{O}_Y)) \cong \mathcal{O}_X$
where $\text{pr}_1 : X \times_Y X \to X$ is the first projection.
We have
$$
\mathcal{O}_X = \Delta^! \text{pr}_1^!\mathcal{O}_X =
\Delta^! \text{pr}_1^! L\text{pr}_2^*\mathcal{O}_Y =
\Delta^!(L\text{pr}_1^* f^!\mathcal{O}_Y)
$$
where $\text{pr}_2 : X \times_Y X \to X$ is the second projection
and where we have used the base change isomorphism
$\text{pr}_1^! \circ L\text{pr}_2^* = L\text{pr}_1^* \circ f^!$ of
Lemma \ref{lemma-base-change-shriek-flat}.
\end{proof}

\begin{lemma}
\label{lemma-relative-dualizing-composition}
Let $f : Y \to X$ and $X \to S$ be morphisms of schemes
which are flat and of finite presentation.
Let $(K, \xi)$ and $(M, \eta)$
be a relative dualizing complex for $X \to S$ and $Y \to X$.
Set $E = M \otimes_{\mathcal{O}_Y}^\mathbf{L} Lf^*K$.
Then $(E, \zeta)$ is a relative dualizing complex for $Y \to S$ for
a suitable $\zeta$.
\end{lemma}

\begin{proof}
Using Lemma \ref{lemma-relative-dualizing-complex-algebra}
and the algebraic version of this lemma (Dualizing Complexes, Lemma
\ref{dualizing-lemma-relative-dualizing-composition})
we see that $E$
is affine locally the first component of a relative dualizing complex.
In particular we see that $E$
is $S$-perfect since this may be checked affine locally, see
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-locally-rel-perfect}.

\medskip\noindent
Let us first prove the existence of $\zeta$ in case the
morphisms $X \to S$ and $Y \to X$ are separated so that
$\Delta_{X/S}$, $\Delta_{Y/X}$, and $\Delta_{Y/S}$
are closed immersions. Consider the following diagram
$$
\xymatrix{
& & Y \ar@{=}[r] & Y \ar[d]^f \\
Y \ar[r]_{\Delta_{Y/X}} &
Y \times_X Y \ar[d]_m \ar[r]_\delta \ar[ru]_q &
Y \times_S Y \ar[d]^{f \times f} \ar[ru]_p & X\\
& X \ar[r]^{\Delta_{X/S}} & X \times_S X \ar[ru]_r
}
$$
where $p$, $q$, $r$ are the first projections.
By Lemma \ref{lemma-sheaf-with-exact-support-internal-home}
we have
$$
R\SheafHom_{\mathcal{O}_{Y \times_S Y}}(
\Delta_{Y/S, *}\mathcal{O}_Y, Lp^*E) =
R\delta_*\left(R\SheafHom_{\mathcal{O}_{Y \times_X Y}}(
\Delta_{Y/X, *}\mathcal{O}_Y,
R\SheafHom(\mathcal{O}_{Y \times_X Y}, Lp^*E))\right)
$$
By Lemma \ref{lemma-sheaf-with-exact-support-tensor} we have
$$
R\SheafHom(\mathcal{O}_{Y \times_X Y}, Lp^*E) =
R\SheafHom(\mathcal{O}_{Y \times_X Y}, L(f \times f)^*Lr^*K)
\otimes_{\mathcal{O}_{Y \times_S Y}}^\mathbf{L} Lq^*M
$$
By Lemma \ref{lemma-flat-bc-sheaf-with-exact-support} we have
$$
R\SheafHom(\mathcal{O}_{Y \times_X Y}, L(f \times f)^*Lr^*K) =
Lm^*R\SheafHom(\mathcal{O}_X, Lr^*K)
$$
The last expression is isomorphic (via $\xi$) to
$Lm^*\mathcal{O}_X = \mathcal{O}_{Y \times_X Y}$.
Hence the expression preceding is isomorphic to
$Lq^*M$. Hence
$$
R\SheafHom_{\mathcal{O}_{Y \times_S Y}}(
\Delta_{Y/S, *}\mathcal{O}_Y, Lp^*E) =
R\delta_*\left(R\SheafHom_{\mathcal{O}_{Y \times_X Y}}(
\Delta_{Y/X, *}\mathcal{O}_Y, Lq^*M)\right)
$$
The material inside the parentheses is isomorphic to
$\Delta_{Y/X, *}*\mathcal{O}_X$ via $\eta$.
This finishes the proof in the separated case.

\medskip\noindent
In the general case we choose an open $W \subset X \times_S X$
such that $\Delta_{X/S}$ factors through a closed immersion
$\Delta : X \to W$ and we choose an open $V \subset Y \times_X Y$
such that $\Delta_{Y/X}$ factors through a closed immersion
$\Delta' : Y \to V$. Finally, choose an open
$W' \subset Y \times_S Y$ whose intersection with $Y \times_X Y$
gives $V$ and which maps into $W$. Then we consider the diagram
$$
\xymatrix{
& & Y \ar@{=}[r] & Y \ar[d]^f \\
Y \ar[r]_{\Delta'} &
V \ar[d]_m \ar[r]_\delta \ar[ru]_q &
W' \ar[d]^{f \times f} \ar[ru]_p & X\\
& X \ar[r]^\Delta & W \ar[ru]_r
}
$$
and we use exactly the same argument as before.
\end{proof}






\section{The fundamental class of an lci morphism}
\label{section-fundamental-class}

\noindent
In this section we will use the computations made in
Section \ref{section-examples}. Thus our result will suffer
from the same kind of non-uniqueness as we have in that section.

\begin{lemma}
\label{lemma-determinant}
Let $X$ be a locally ringed space. Let
$$
\mathcal{E}_1 \xrightarrow{\alpha} \mathcal{E}_0 \to \mathcal{F} \to 0
$$
be a short exact sequence of $\mathcal{O}_X$-modules.
Assume $\mathcal{E}_1$ and $\mathcal{E}_0$ are locally
free of ranks $r_1, r_0$. Then there is a canonical map
$$
\wedge^{r_0 - r_1}\mathcal{F}
\longrightarrow
\wedge^{r_1}(\mathcal{E}_1^\vee) \otimes \wedge^{r_0}\mathcal{E}_0
$$
which is an isomorphism on the stalk at $x \in X$
if and only if $\mathcal{F}$ is locally free of rank $r_0 - r_1$
in an open neighbourhood of $x$.
\end{lemma}

\begin{proof}
If $r_1 > r_0$ then $\wedge^{r_0 - r_1}\mathcal{F} = 0$ by convention
and the unique map cannot be an isomorphism. Thus we may assume
$r = r_0 - r_1 \geq 0$. Define the map by the formula
$$
s_1 \wedge \ldots \wedge s_r \mapsto
t_1^\vee \wedge \ldots \wedge t_{r_1}^\vee \otimes
\alpha(t_1) \wedge \ldots \wedge \alpha(t_{r_1}) \wedge
\tilde s_1 \wedge \ldots \wedge \tilde s_r
$$
where $t_1, \ldots, t_{r_1}$ is a local basis for $\mathcal{E}_1$,
correspondingly
$t_1^\vee, \ldots, t_{r_1}^\vee$ is the dual basis for $\mathcal{E}_1^\vee$,
and $s'_i$ is a local lift of $s_i$ to a section of $\mathcal{E}_0$.
We omit the proof that this is well defined.

\medskip\noindent
If $\mathcal{F}$ is locally free of rank $r$, then it is straightforward
to verify that the map is an isomorphism. Conversely, assume the map
is an isomorphism on stalks at $x$. Then $\wedge^r\mathcal{F}_x$
is invertible. This implies that $\mathcal{F}_x$ is generated by
at most $r$ elements. This can only happen if $\alpha$ has rank
$r$ modulo $\mathfrak m_x$, i.e., $\alpha$ has maximal rank modulo
$\mathfrak m_x$. This implies that $\alpha$ has maximal rank
in a neighbourhood of $x$ and hence $\mathcal{F}$ is locally free
of rank $r$ in a neighbourhood as desired.
\end{proof}

\begin{lemma}
\label{lemma-fundamental-class-lci}
Let $Y$ be a Noetherian scheme. Let $f : X \to Y$ be a
local complete intersection morphism which factors
as an immersion $X \to P$ followed by a proper smooth morphism $P \to Y$.
Let $r$ be the locally constant function on
$X$ such that $\omega_{X/Y} = H^{-r}(f^!\mathcal{O}_Y)$
is the unique nonzero cohomology sheaf of $f^!\mathcal{O}_Y$, see
Lemma \ref{lemma-lci-shriek}.
Then there is a map
$$
\wedge^r\Omega_{X/Y} \longrightarrow \omega_{X/Y}
$$
which is an isomorphism on the stalk at a point $x$ if and only
if $f$ is smooth at $x$.
\end{lemma}

\begin{proof}
The assumption implies that $X$ is compactifiable over $Y$ hence $f^!$
is defined, see Section \ref{section-upper-shriek}.
Let $j : W \to P$ be an open subscheme such that
$X \to P$ factors through a closed immersion $i : X \to W$.
Moreover, we have $f^! = i^! \circ j^! \circ g^!$ where
$g : P \to Y$ is the given morphism.
We have $g^!\mathcal{O}_Y = \wedge^d\Omega_{P/Y}[d]$ by
Lemma \ref{lemma-smooth-proper} where $d$ is the locally
constant function giving the relative dimension of $P$ over $Y$.
We have $j^! = j^*$. We have $i^!\mathcal{O}_W = \wedge^c\mathcal{N}[-c]$
where $c$ is the codimension of $X$ in $W$ (a locally constant
function on $X$) and where $\mathcal{N}$ is the normal sheaf of
the Koszul-regular immersion $i$, see Lemma \ref{lemma-regular-immersion}.
Combining the above we find
$$
f^!\mathcal{O}_Y =
\left(\wedge^c\mathcal{N} \otimes_{\mathcal{O}_X}
\wedge^d\Omega_{P/Y}|_X\right)[d - c]
$$
where we have also used Lemma \ref{lemma-perfect-comparison-shriek}.
Thus $r = d|_X - c$ as locally constant functions on $X$.
The conormal sheaf of $X \to P$ is the module
$\mathcal{I}/\mathcal{I}^2$ where $\mathcal{I} \subset \mathcal{O}_W$
is the ideal sheaf of $i$, see
Morphisms, Section \ref{morphisms-section-conormal-sheaf}.
Consider the canonical exact sequence
$$
\mathcal{I}/\mathcal{I}^2 \to
\Omega_{P/Y}|_X \to \Omega_{X/Y} \to 0
$$
of Morphisms, Lemma \ref{morphisms-lemma-differentials-relative-immersion}.
We obtain our map by an application of Lemma \ref{lemma-determinant}.

\medskip\noindent
If $f$ is smooth at $x$, then the map is an isomorphism by an application of
Lemma \ref{lemma-determinant}
and the fact that $\Omega_{X/Y}$ is locally free at $x$
of rank $r$. Conversely, assume that our map is an isomorphism on stalks
at $x$. Then the lemma shows that $\Omega_{X/Y}$ is free of rank $r$
after replacing $X$ by an open neighbourhood of $x$.
On the other hand, we may also assume that $X = \Spec(A)$ and
$Y = \Spec(R)$ where $A = R[x_1, \ldots, x_n]/(f_1, \ldots, f_m)$
and where $f_1, \ldots, f_m$ is a Koszul regular sequence
(this follows from the definition of local complete intersection morphisms).
Clearly this implies $r = n - m$. We conclude that the rank of the matrix
of partials $\partial f_j/\partial x_i$ in the residue field at $x$ is $m$.
Thus after reordering the variables we may assume
the determinant of $(\partial f_j/\partial x_i)_{1 \leq i, j \leq m}$
is invertible in an open neighbourhood of $x$. It follows
that $R \to A$ is smooth at this point, see for example
Algebra, Example \ref{algebra-example-make-standard-smooth}.
\end{proof}

\begin{lemma}
\label{lemma-fundamental-class-almost-lci}
Let $f : X \to Y$ be a morphism of schemes. Let $r \geq 0$. Assume
\begin{enumerate}
\item $Y$ is Cohen-Macaulay (Properties, Definition
\ref{properties-definition-Cohen-Macaulay}),
\item $f$ factors as $X \to P \to Y$ where the first morphism is
an immersion and the second is smooth and proper,
\item if $x \in X$ and $\dim(\mathcal{O}_{X, x}) \leq 1$,
then $f$ is Koszul at $x$ (More on Morphisms, Definition
\ref{more-morphisms-definition-lci}), and
\item if $\xi$ is a generic point of an irreducible component of $X$, then
we have
$\text{trdeg}_{\kappa(f(\xi))} \kappa(\xi) = r$.
\end{enumerate}
Then with $\omega_{X/Y} = H^{-r}(f^!\mathcal{O}_Y)$ there is a map
$$
\wedge^r\Omega_{X/Y} \longrightarrow \omega_{X/Y}
$$
which is an isomorphism on the locus where $f$ is smooth.
\end{lemma}

\begin{proof}
Let $U \subset X$ be the open subscheme over which $f$ is a
local complete intersection morphism. Since $f$ has relative
dimension $r$ at all generic points by assumption (4) we
see that the locally constant function of
Lemma \ref{lemma-fundamental-class-lci}
is constant with value $r$ and we obtain a map
$$
\wedge^r\Omega_{X/Y}|_U = \wedge^r \Omega_{U/Y}
\longrightarrow
\omega_{U/Y} = \omega_{X/Y}|_U
$$
which is an isomorphism in the smooth points of $f$ (this locus
is contained in $U$ because a smooth morphism is a local complete
intersection morphism). By Lemma \ref{lemma-shriek-over-CM}
and the assumption that $Y$ is Cohen-Macaulay
the module $\omega_{X/Y}$ is $(S_2)$.
Since $U$ contains all the points of codimension $1$ by condition (3)
and using Divisors, Lemma \ref{divisors-lemma-depth-2-hartog}
we see that $j_*\omega_{U/Y} = \omega_{X/Y}$.
Hence the map over $U$ extends to $X$ and the proof
is complete.
\end{proof}






\section{Extension by zero for coherent modules}
\label{section-extension-by-zero}

\noindent
The material in this section and the next few can be found
in the appendix by Deligne of \cite{RD}.

\medskip\noindent
In this section $j : U \to X$ will be an open immersion of Noetherian schemes.
We are going to consider inverse systems $(K_n)$ in
$D^b_{\textit{Coh}}(\mathcal{O}_X)$ constructed as follows.
Let $\mathcal{F}^\bullet$ be a bounded complex of coherent
$\mathcal{O}_X$-modules. Let $\mathcal{I} \subset \mathcal{O}_X$
be a quasi-coherent sheaf of ideals with $V(\mathcal{I}) = X \setminus U$.
Then we can set
$$
K_n = \mathcal{I}^n\mathcal{F}^\bullet
$$
More precisely, $K_n$ is the object of $D^b_{\textit{Coh}}(\mathcal{O}_X)$
represented by the complex whose term in degree $q$
is the coherent submodule $\mathcal{I}^n\mathcal{F}^q$ of $\mathcal{F}^q$.
Observe that the maps $\ldots \to K_3 \to K_2 \to K_1$ induce isomorphisms
on restriction to $U$. Let us call such a system a {\it Deligne system}.

\begin{lemma}
\label{lemma-lift-map}
Let $j : U \to X$ be an open immersion of Noetherian schemes.
Let $(K_n)$ be a Deligne system and denote
$K \in D^b_{\textit{Coh}}(\mathcal{O}_U)$ the value
of the constant system $(K_n|_U)$. Let $L$ be an object of
$D^b_{\textit{Coh}}(\mathcal{O}_X)$.
Then $\colim \Hom_X(K_n, L) = \Hom_U(K, L|_U)$.
\end{lemma}

\begin{proof}
Let $L \to M \to N \to L[1]$ be a distinguished triangle in
$D^b_{\textit{Coh}}(\mathcal{O}_X)$. Then we obtain
a commutative diagram
$$
\xymatrix{
\ldots \ar[r] &
\colim \Hom_X(K_n, L) \ar[r] \ar[d] &
\colim \Hom_X(K_n, M) \ar[r] \ar[d] &
\colim \Hom_X(K_n, N) \ar[r] \ar[d] &
\ldots \\
\ldots \ar[r] &
\Hom_U(K, L|_U) \ar[r] &
\Hom_U(K, M|_U) \ar[r] &
\Hom_U(K, N|_U) \ar[r] &
\ldots
}
$$
whose rows are exact by Derived Categories, Lemma
\ref{derived-lemma-representable-homological} and
Algebra, Lemma \ref{algebra-lemma-directed-colimit-exact}.
Hence if the statement of the lemma holds for
$N[-1]$, $L$, $N$, and $L[1]$ then it holds for $M$ by the 5-lemma.
Thus, using the distinguished triangles
for the canonical truncations of $L$ (see Derived Categories, Remark
\ref{derived-remark-truncation-distinguished-triangle})
we reduce to the case that $L$ has only one nonzero cohomology sheaf.

\medskip\noindent
Choose a bounded complex $\mathcal{F}^\bullet$ of coherent
$\mathcal{O}_X$-modules and a quasi-coherent ideal
$\mathcal{I} \subset \mathcal{O}_X$ cutting out $X \setminus U$
such that $K_n$ is represented by $\mathcal{I}^n\mathcal{F}^\bullet$.
Using ``stupid'' truncations we obtain compatible termwise split short
exact sequences of complexes
$$
0 \to \sigma_{\geq a + 1} \mathcal{I}^n\mathcal{F}^\bullet \to
\mathcal{I}^n\mathcal{F}^\bullet \to
\sigma_{\leq a} \mathcal{I}^n\mathcal{F}^\bullet \to 0
$$
which in turn correspond to compatible systems of distinguished
triangles in $D^b_{\textit{Coh}}(\mathcal{O}_X)$.
Arguing as above we reduce to the case where $\mathcal{F}^\bullet$
has only one nonzero term. This reduces us to the case discussed in
the next paragraph.

\medskip\noindent
Given a coherent $\mathcal{O}_X$-module $\mathcal{F}$ and a coherent
$\mathcal{O}_X$-module $\mathcal{G}$ we
have to show that the canonical map
$$
\colim \Ext^i_X(\mathcal{I}^n\mathcal{F}, \mathcal{G})
\longrightarrow
\Ext^i_U(\mathcal{F}|_U, \mathcal{G}|_U)
$$
is an isomorphism for all $i \geq 0$. For $i = 0$ this is
Cohomology of Schemes, Lemma \ref{coherent-lemma-homs-over-open}.
Assume $i > 0$.

\medskip\noindent
Injectivity. Let $\xi \in \Ext^i_X(\mathcal{I}^n\mathcal{F}, \mathcal{G})$
be an element whose restriction to $U$ is zero. We have to show there exists
an $m \geq n$ such that the restriction of $\xi$ to
$\mathcal{I}^m\mathcal{F} = \mathcal{I}^{m - n}\mathcal{I}^n\mathcal{F}$
is zero. After replacing $\mathcal{F}$ by $\mathcal{I}^n\mathcal{F}$
we may assume $n = 0$, i.e., we have
$\xi \in \Ext^i_X(\mathcal{F}, \mathcal{G})$
whose restriction to $U$ is zero. By
Derived Categories of Schemes, Proposition \ref{perfect-proposition-DCoh}
we have
$D^b_{\textit{Coh}}(\mathcal{O}_X) = D^b(\textit{Coh}(\mathcal{O}_X))$.
Hence we can compute the $\Ext$ group in the abelian category of
coherent $\mathcal{O}_X$-modules. This implies there exists an
surjection $\alpha : \mathcal{F}'' \to \mathcal{F}$ such that
$\xi \circ \alpha = 0$ (this is where we use that $i > 0$).
Set $\mathcal{F}' = \Ker(\alpha)$ so that we have a short exact
sequence
$$
0 \to \mathcal{F}' \to \mathcal{F}'' \to \mathcal{F} \to 0
$$
It follows that $\xi$ is the image of an element
$\xi' \in \Ext^{i - 1}_X(\mathcal{F}', \mathcal{G})$
whose restriction to $U$ is in the image of
$\Ext^{i - 1}_U(\mathcal{F}''|_U, \mathcal{G}|_U) \to
\Ext^{i - 1}_U(\mathcal{F}'|_U, \mathcal{G}|_U)$.
By Artin-Rees the inverse systems $(\mathcal{I}^n\mathcal{F}')$ and
$(\mathcal{I}^n \mathcal{F}'' \cap \mathcal{F}')$ are pro-isomorphic, see
Cohomology of Schemes, Lemma \ref{coherent-lemma-Artin-Rees}.
Since we have the compatible system of short exact sequences
$$
0 \to
\mathcal{F}' \cap \mathcal{I}^n\mathcal{F}'' \to
\mathcal{I}^n\mathcal{F}'' \to
\mathcal{I}^n\mathcal{F} \to 0
$$
we obtain a commutative diagram
$$
\xymatrix{
\colim \Ext^{i - 1}_X(\mathcal{I}^n\mathcal{F}'', \mathcal{G})
\ar[r] \ar[d] &
\colim \Ext^{i - 1}_X(\mathcal{F}' \cap \mathcal{I}^n\mathcal{F}'', \mathcal{G})
\ar[r] \ar[d] &
\colim \Ext^i_X(\mathcal{I}^n\mathcal{F}, \mathcal{G})
\ar[d] \\
\Ext^{i - 1}_U(\mathcal{F}''|_U, \mathcal{G}|_U) \ar[r] &
\Ext^{i - 1}_U(\mathcal{F}'|_U, \mathcal{G}|_U) \ar[r] &
\Ext^{i - 1}_U(\mathcal{F}|_U, \mathcal{G}|_U)
}
$$
with exact rows. By induction on $i$ and the comment on inverse systems above
we find that the left two vertical arrows are isomorphisms.
Now $\xi$ gives an element in the top right group which is the image
of $\xi'$ in the middle top group, which in turn maps to an element of
the bottom middle group coming from some element in the left bottom group.
We conclude that $\xi$ maps to zero in
$\Ext^i_X(\mathcal{I}^n\mathcal{F}, \mathcal{G})$
for some $n$ as desired.

\medskip\noindent
Surjectivity. Let $\xi \in \Ext^i_U(\mathcal{F}|_U, \mathcal{G}|_U)$.
Arguing as above using that $i > 0$ we can find an surjection
$\mathcal{H} \to \mathcal{F}|_U$ of coherent $\mathcal{O}_U$-modules
such that $\xi$ maps to zero in $\Ext^i_U(\mathcal{H}, \mathcal{G}|_U)$.
Then we can find a map $\varphi : \mathcal{F}'' \to \mathcal{F}$
of coherent $\mathcal{O}_X$-modules whose restriction to $U$ is
$\mathcal{H} \to \mathcal{F}|_U$, see
Properties, Lemma \ref{properties-lemma-extend-finite-presentation}.
Observe that the lemma doesn't guarantee $\varphi$ is surjective
but this won't matter (it is possible to pick a surjective $\varphi$
with a little bit of additional work).
Denote $\mathcal{F}' = \Ker(\varphi)$. The short exact sequence
$$
0 \to \mathcal{F}'|_U \to \mathcal{F}''|_U \to \mathcal{F}|_U \to 0
$$
shows that $\xi$ is the image of $\xi'$ in
$\Ext^{i - 1}_U(\mathcal{F}'|_U, \mathcal{G}|_U)$.
By induction on $i$ we can find an $n$ such that
$\xi'$ is the image of some $\xi'_n$ in
$\Ext^{i - 1}_X(\mathcal{I}^n\mathcal{F}', \mathcal{G})$.
By Artin-Rees we can find an $m \geq n$ such that
$\mathcal{F}' \cap \mathcal{I}^m\mathcal{F}'' \subset
\mathcal{I}^n\mathcal{F}'$. Using the short exact sequence
$$
0 \to \mathcal{F}' \cap \mathcal{I}^m\mathcal{F}'' \to
\mathcal{I}^m\mathcal{F}'' \to \mathcal{I}^m\Im(\varphi) \to 0
$$
the image of $\xi'_n$ in
$\Ext^{i - 1}_X(\mathcal{F}' \cap \mathcal{I}^m\mathcal{F}'', \mathcal{G})$
maps by the boundary map to an element $\xi_m$ of
$\Ext^i_X(\mathcal{I}^m\Im(\varphi), \mathcal{G})$ which maps
to $\xi$. Since $\Im(\varphi)$ and $\mathcal{F}$ agree over $U$
we see that $\mathcal{F}/\mathcal{I}^m\Im(\varphi)$ is supported
on $X \setminus U$. Hence there exists an $l \geq m$
such that $\mathcal{I}^l\mathcal{F} \subset \mathcal{I}^m\Im(\varphi)$, see
Cohomology of Schemes, Lemma \ref{coherent-lemma-power-ideal-kills-sheaf}.
Taking the image of $\xi_m$ in
$\Ext^i_X(\mathcal{I}^l\mathcal{F}, \mathcal{G})$ we win.
\end{proof}

\begin{lemma}
\label{lemma-lift-map-plus}
The result of Lemma \ref{lemma-lift-map} holds even for
$L \in D^+_{\textit{Coh}}(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Namely, if $(K_n)$ is a Deligne system then there exists a
$b \in \mathbf{Z}$ such that $H^i(K_n) = 0$ for $i > b$.
Then $\Hom(K_n, L) = \Hom(K_n, \tau_{\leq b}L)$ and
$\Hom(K, L) = \Hom(K, \tau_{\leq b}L)$. Hence using
the result of the lemma for $\tau_{\leq b}L$ we win.
\end{proof}

\begin{lemma}
\label{lemma-extension-by-zero}
Let $j : U \to X$ be an open immersion of Noetherian schemes.
\begin{enumerate}
\item Let $(K_n)$ and $(L_n)$ be Deligne systems.
Let $K$ and $L$ be the values of the constant systems
$(K_n|_U)$ and $(L_n|_U)$. Given a morphism $\alpha : K \to L$
of $D(\mathcal{O}_U)$
there is a unique morphism of pro-systems $(K_n) \to (L_n)$
of $D^b_{\textit{Coh}}(\mathcal{O}_X)$ whose restriction to $U$ is $\alpha$.
\item Given $K \in D^b_{\textit{Coh}}(\mathcal{O}_U)$ there exists a
Deligne system $(K_n)$ such that $(K_n|_U)$ is constant
with value $K$.
\item The pro-object $(K_n)$ of $D^b_{\textit{Coh}}(\mathcal{O}_X)$
of (2) is unique up to unique isomorphism (as a pro-object).
\end{enumerate}
\end{lemma}

\begin{proof}
Part (1) is an immediate consequence of Lemma \ref{lemma-lift-map}
and the fact that morphisms between pro-systems are
the same as morphisms between the functors they corepresent, see
Categories, Remark \ref{categories-remark-pro-category-copresheaves}.

\medskip\noindent
Let $K$ be as in (2). We can choose $K' \in D^b_{\textit{Coh}}(\mathcal{O}_X)$
whose restriction to $U$ is isomorphic to $K$, see
Derived Categories of Schemes, Lemma \ref{perfect-lemma-lift-coherent}.
By Derived Categories of Schemes, Proposition \ref{perfect-proposition-DCoh}
we can represent $K'$ by a bounded complex $\mathcal{F}^\bullet$
of coherent $\mathcal{O}_X$-modules. Choose a quasi-coherent sheaf
of ideals $\mathcal{I} \subset \mathcal{O}_X$ whose vanishing
locus is $X \setminus U$ (for example choose $\mathcal{I}$ to correspond
to the reduced induced subscheme structure on $X \setminus U$).
Then we can set $K_n$ equal to the object represented by the complex
$\mathcal{I}^n\mathcal{F}^\bullet$ as in the introduction
to this section.

\medskip\noindent
Part (3) is immediate from parts (1) and (2).
\end{proof}

\begin{lemma}
\label{lemma-extension-by-zero-triangle}
Let $j : U \to X$ be an open immersion of Noetherian schemes. Let
$$
K \to L \to M \to K[1]
$$
be a distinguished triangle of $D^b_{\textit{Coh}}(\mathcal{O}_U)$.
Then there exists an inverse system of distinguished triangles
$$
K_n \to L_n \to M_n \to K_n[1]
$$
in $D^b_{\textit{Coh}}(\mathcal{O}_X)$ such that $(K_n)$, $(L_n)$, $(M_n)$
are Deligne systems and such that the restriction of these
distinguished triangles to $U$ is isomorphic to the distinguished triangle
we started out with.
\end{lemma}

\begin{proof}
Let $(K_n)$ be as in Lemma \ref{lemma-extension-by-zero} part (2).
Choose an object $L'$ of $D^b_{\textit{Coh}}(\mathcal{O}_X)$
whose restriction to $U$ is $L$ (we can do this as the lemma shows).
By Lemma \ref{lemma-lift-map} we can find an $n$ and a morphism
$K_n \to L'$ on $X$ whose restriction to $U$ is the given arrow
$K \to L$. We conclude there is a morphism $K' \to L'$ of
$D^b_{\textit{Coh}}(\mathcal{O}_X)$ whose restriction to $U$
is the given arrow $K \to L$.

\medskip\noindent
By Derived Categories of Schemes, Proposition \ref{perfect-proposition-DCoh}
we can find a morphism $\alpha^\bullet : \mathcal{F}^\bullet \to
\mathcal{G}^\bullet$ of bounded complexes
of coherent $\mathcal{O}_X$-modules representing $K' \to L'$.
Choose a quasi-coherent sheaf of ideals $\mathcal{I} \subset \mathcal{O}_X$
whose vanishing locus is $X \setminus U$.
Then we let
$K_n = \mathcal{I}^n\mathcal{F}^\bullet$
and
$L_n = \mathcal{I}^n\mathcal{G}^\bullet$.
Observe that $\alpha^\bullet$ induces a morphism of
complexes $\alpha_n^\bullet : \mathcal{I}^n\mathcal{F}^\bullet \to
\mathcal{I}^n\mathcal{G}^\bullet$. From the construction of cones in
Derived Categories, Section \ref{derived-section-cones}
it is clear that
$$
C(\alpha_n)^\bullet = \mathcal{I}^nC(\alpha^\bullet)
$$
and hence we can set $M_n = C(\alpha_n)^\bullet$. Namely, we
have a compatible system of distinguished triangles
(see discussion in Derived Categories, Section
\ref{derived-section-canonical-delta-functor})
$$
K_n \to L_n \to M_n \to K_n[1]
$$
whose restriction to $U$ is isomorphic to the distinguished 
triangle we started out with by axiom TR3 and Derived Categories,
Lemma \ref{derived-lemma-third-isomorphism-triangle}.
\end{proof}

\begin{remark}
\label{remark-extension-by-zero}
Let $j : U \to X$ be an open immersion of Noetherian schemes.
Sending $K \in D^b_{\textit{Coh}}(\mathcal{O}_U)$ to a Deligne
system whose restriction to $U$ is $K$ determines a functor
$$
Rj_! :
D^b_{\textit{Coh}}(\mathcal{O}_U)
\longrightarrow
\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_X)
$$
which is ``exact'' by Lemma \ref{lemma-extension-by-zero-triangle} and
which is
``left adjoint'' to the functor
$j^* : D^b_{\textit{Coh}}(\mathcal{O}_X) \to
D^b_{\textit{Coh}}(\mathcal{O}_U)$ by Lemma \ref{lemma-lift-map}.
\end{remark}

\begin{remark}
\label{remark-extension-by-zero-linear-pro-system}
Let $(A_n)$ and $(B_n)$ be inverse systems of a category $\mathcal{C}$.
Let us say a linear-pro-morphism from $(A_n)$ to $(B_n)$ is given
by a compatible family of morphisms $\varphi_n : A_{cn + d} \to B_n$
for all $n \geq 1$ for some fixed integers $c, d \geq 1$.
We'll say $(\varphi_n : A_{cn + d} \to B_n)$ and
$(\psi_n : A_{c'n + d'} \to B_n)$ determine the same morphism
if there exist $c'' \geq \max(c, c')$ and $d'' \geq \max(d, d')$
such that the two induced morphisms $A_{c'' n + d''} \to B_n$ are the same
for all $n$. It seems likely that Deligne systems $(K_n)$ with given value on
$U$ are well defined up to linear-pro-isomorphisms. If we ever need this
we will carefully formulate and prove this here.
\end{remark}

\begin{lemma}
\label{lemma-deligne-system-2-out-of-3}
Let $j : U \to X$ be an open immersion of Noetherian schemes.
Let
$$
K_n \to L_n \to M_n \to K_n[1]
$$
be an inverse system of distinguished triangles in
$D^b_{\textit{Coh}}(\mathcal{O}_X)$. If $(K_n)$ and $(M_n)$
are pro-isomorphic to Deligne systems, then so is $(L_n)$.
\end{lemma}

\begin{proof}
Observe that the systems $(K_n|_U)$ and $(M_n|_U)$ are essentially constant
as they are pro-isomorphic to constant systems.
Denote $K$ and $M$ their values. By Derived Categories, Lemma
\ref{derived-lemma-essentially-constant-2-out-of-3}
we see that the inverse system $L_n|_U$ is essentially constant as well.
Denote $L$ its value.
Let $N \in D^b_{\textit{Coh}}(\mathcal{O}_X)$. Consider the commutative
diagram
$$
\xymatrix{
\ldots \ar[r] &
\colim \Hom_X(M_n, N) \ar[r] \ar[d] &
\colim \Hom_X(L_n, N) \ar[r] \ar[d] &
\colim \Hom_X(K_n, N) \ar[r] \ar[d] &
\ldots \\
\ldots \ar[r] &
\Hom_U(M, N|_U) \ar[r] &
\Hom_U(L, N|_U) \ar[r] &
\Hom_U(K, N|_U) \ar[r] &
\ldots
}
$$
By Lemma \ref{lemma-lift-map} and the fact that isomorphic ind-systems
have the same colimit, we see that the vertical arrows two to the right
and two to the left of the middle one are isomorphisms. By the 5-lemma
we conclude that the
middle vertical arrow is an isomorphism. Now, if $(L'_n)$ is a Deligne system
whose restriction to $U$ has constant value $L$ (which
exists by Lemma \ref{lemma-extension-by-zero}), then
we have $\colim \Hom_X(L'_n, N) = \Hom_U(L, N|_U)$ as well.
Hence the pro-systems $(L_n)$ and $(L'_n)$ are
pro-isomorphic by
Categories, Remark \ref{categories-remark-pro-category-copresheaves}.
\end{proof}

\begin{lemma}
\label{lemma-consequence-Artin-Rees-bis}
Let $X$ be a Noetherian scheme. Let $\mathcal{I} \subset \mathcal{O}_X$
be a quasi-coherent sheaf of ideals. Let $\mathcal{F}^\bullet$ be a
complex of coherent $\mathcal{O}_X$-modules. Let $p \in \mathbf{Z}$.
Set $\mathcal{H} = H^p(\mathcal{F}^\bullet)$ and
$\mathcal{H}_n = H^p(\mathcal{I}^n\mathcal{F}^\bullet)$.
Then there are canonical $\mathcal{O}_X$-module maps
$$
\ldots \to \mathcal{H}_3 \to \mathcal{H}_2 \to \mathcal{H}_1 \to \mathcal{H}
$$
There exists a $c > 0$ such that for $n \geq c$ the image of
$\mathcal{H}_n \to \mathcal{H}$ is contained in
$\mathcal{I}^{n - c}\mathcal{H}$ and there is a canonical
$\mathcal{O}_X$-module map
$\mathcal{I}^n\mathcal{H} \to \mathcal{H}_{n - c}$ such that the compositions
$$
\mathcal{I}^n \mathcal{H} \to \mathcal{H}_{n - c} \to
\mathcal{I}^{n - 2c}\mathcal{H}
\quad\text{and}\quad
\mathcal{H}_n \to \mathcal{I}^{n - c}\mathcal{H} \to \mathcal{H}_{n - 2c}
$$
are the canonical ones. In particular, the inverse systems
$(\mathcal{H}_n)$ and $(\mathcal{I}^n\mathcal{H})$
are isomorphic as pro-objects of $\textit{Mod}(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
If $X$ is affine, translated into algebra this is More on Algebra, Lemma
\ref{more-algebra-lemma-consequence-Artin-Rees-bis}.
In the general case, argue exactly as in the proof of that lemma
replacing the reference to Artin-Rees in algebra with a reference to
Cohomology of Schemes, Lemma \ref{coherent-lemma-Artin-Rees}.
Details omitted.
\end{proof}

\begin{lemma}
\label{lemma-characterize-extension-by-zero-algebra}
Let $j : U \to X$ be an open immersion of Noetherian schemes.
Let $a \leq b$ be integers. Let $(K_n)$ be an inverse system of
$D^b_{\textit{Coh}}(\mathcal{O}_X)$
such that $H^i(K_n) = 0$ for $i \not \in [a, b]$.
The following are equivalent
\begin{enumerate}
\item $(K_n)$ is pro-isomorphic to a Deligne system,
\item for every $p \in \mathbf{Z}$ there exists a coherent
$\mathcal{O}_X$-module $\mathcal{F}$ such that the pro-systems
$(H^p(K_n))$ and $(\mathcal{I}^n\mathcal{F})$ are pro-isomorphic.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume (1). To prove (2) holds we may assume $(K_n)$ is a Deligne system.
By definition we may choose a bounded complex $\mathcal{F}^\bullet$
of coherent $\mathcal{O}_X$-modules and a quasi-coherent
sheaf of ideals cutting out $X \setminus U$ such that
$K_n$ is represented by $\mathcal{I}^n\mathcal{F}^\bullet$.
Thus the result follows from Lemma \ref{lemma-consequence-Artin-Rees-bis}.

\medskip\noindent
Assume (2). We will prove that $(K_n)$ is as in (1) by induction on
$b - a$. If $a = b$ then (1) holds essentially by assumption.
If $a < b$ then we consider the compatible system of
distinguished triangles
$$
\tau_{\leq a}K_n \to K_n \to \tau_{\geq a + 1}K_n \to (\tau_{\leq a}K_n)[1]
$$
See Derived Categories, Remark
\ref{derived-remark-truncation-distinguished-triangle}.
By induction on $b - a$ we know that $\tau_{\leq a}K_n$ and
$\tau_{\geq a + 1}K_n$ are pro-isomorphic to Deligne systems.
We conclude by Lemma \ref{lemma-deligne-system-2-out-of-3}.
\end{proof}

\begin{lemma}
\label{lemma-characterize-extension-by-zero}
Let $j : U \to X$ be an open immersion of Noetherian schemes. Let
$(K_n)$ be an inverse system in $D^b_{\textit{Coh}}(\mathcal{O}_X)$.
Let $X = W_1 \cup \ldots \cup W_r$ be an open covering.
The following are equivalent
\begin{enumerate}
\item $(K_n)$ is pro-isomorphic to a Deligne system,
\item for each $i$ the restriction $(K_n|_{W_i})$
is pro-isomorphic to a Deligne system with respect to
the open immersion $U \cap W_i \to W_i$.
\end{enumerate}
\end{lemma}

\begin{proof}
By induction on $r$. If $r = 1$ then the result is clear.
Assume $r > 1$. Set $V = W_1 \cup \ldots \cup W_{r - 1}$.
By induction we see that $(K_n|_V)$ is a Deligne system.
This reduces us to the discussion in the next paragraph.

\medskip\noindent
Assume $X = V \cup W$ is an open covering and
$(K_n|_W)$ and $(K_n|_V)$ are pro-isomorphic to Deligne systems.
We have to show that $(K_n)$ is pro-isomorphic to a Deligne system.
Observe that $(K_n|_{V \cap W})$ is pro-isomorphic to a Deligne system
(it follows immediately from the construction of Deligne systems
that restrictions to opens preserves them). In particular the pro-systems
$(K_n|_{U \cap V})$,
$(K_n|_{U \cap W})$, and
$(K_n|_{U \cap V \cap W})$
are essentially constant. It follows from the distinguished triangles
in Cohomology, Lemma \ref{cohomology-lemma-exact-sequence-j-star} and
Derived Categories, Lemma \ref{derived-lemma-essentially-constant-2-out-of-3}
that $(K_n|_U)$ is essentially constant.
Denote $K \in D^b_{\textit{Coh}}(\mathcal{O}_U)$ the value of this system.
Let $L$ be an object of $D^b_{\textit{Coh}}(\mathcal{O}_X)$.
Consider the diagram
$$
\xymatrix{
\colim \Ext^{-1}(K_n|_V, L|_V) \oplus
\colim \Ext^{-1}(K_n|_W, L|_W) \ar[r] \ar[d] &
\Ext^{-1}(K|_{U \cap V}, L|_{U \cap V}) \oplus
\Ext^{-1}(K|_{U \cap W}, L|_{U \cap W}) \ar[d] \\
\colim \Ext^{-1}(K_n|_{V \cap W}, L|_{V \cap W}) \ar[r] \ar[d] &
\Ext^{-1}(K|_{U \cap V \cap W}, L|_{U \cap V \cap W}) \ar[d] \\
\colim \Hom(K_n, L) \ar[d] \ar[r] &
\Hom(K|_U, L|_U) \ar[d] \\
\colim \Hom(K_n|_V, L|_V) \oplus \colim \Hom(K_n|_W, L|_W) \ar[r] \ar[d] &
\Hom(K|_{U \cap V}, L|_{U \cap V}) \oplus
\Hom(K|_{U \cap W}, L|_{U \cap W}) \ar[d] \\
\colim \Hom(K_n|_{V \cap W}, L|_{V \cap W}) \ar[r] &
\Hom(K|_{U \cap V \cap W}, L|_{U \cap V \cap W})
}
$$
The vertical sequences are exact by
Cohomology, Lemma \ref{cohomology-lemma-mayer-vietoris-hom}
and the fact that filtered colimits are exact.
All horizontal arrows except for the middle one are isomorphisms
by Lemma \ref{lemma-lift-map} and the fact that pro-isomorphic systems
have the same colimits. Hence the middle one is an isomorphism too by
the 5-lemma. It follows that $(K_n)$ is pro-isomorphic to
a Deligne system for $K$. Namey, if $(K'_n)$ is a Deligne system
whose restriction to $U$ has constant value $K$ (which
exists by Lemma \ref{lemma-extension-by-zero}), then
we have $\colim \Hom_X(K'_n, L) = \Hom_U(K, L|_U)$ as well.
Hence the pro-systems $(K_n)$ and $(K'_n)$ are
pro-isomorphic by
Categories, Remark \ref{categories-remark-pro-category-copresheaves}.
\end{proof}

\begin{lemma}
\label{lemma-tensoring-Deligne-system}
Let $j : U \to X$ be an open immersion of Noetherian schemes. Let
$\mathcal{I} \subset \mathcal{O}_X$ be a quasi-coherent sheaf of
ideals with $V(\mathcal{I}) = X \setminus U$.
Let $K$ be in $D^b_{\textit{Coh}}(\mathcal{O}_X)$.
Then
$$
K \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{I}^n
$$
is pro-isomorphic to a Deligne system with constant value $K|_U$ over $U$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-characterize-extension-by-zero} the question is
local on $X$. Thus we may assume $X$ is the spectrum of a Noetherian
ring. In this case the statement follows from the algebra version which is
More on Algebra, Lemma \ref{more-algebra-lemma-tensoring-Deligne-system}.
\end{proof}







\section{Preliminaries to compactly supported cohomology}
\label{section-preliminaries-compactly-supported}

\noindent
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism
in the category $\textit{FTS}_S$. Using the constructions in the
previous section, we will construct a functor
$$
Rf_! :
D^b_{\textit{Coh}}(\mathcal{O}_X)
\longrightarrow
\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)
$$
which reduces to the functor of Remark \ref{remark-extension-by-zero}
if $f$ is an open immersion and in general is constructed using a
compactification of $f$. Before we do this, we need the following lemmas
to prove our construction is well defined.

\begin{lemma}
\label{lemma-well-defined-pre}
Let $f : X \to Y$ be a proper morphism of Noetherian schemes.
Let $V \subset Y$ be an open subscheme and set $U = f^{-1}(V)$.
Picture
$$
\xymatrix{
U \ar[r]_j \ar[d]_g & X \ar[d]^f \\
V \ar[r]^{j'} & Y
}
$$
Then we have a canonical isomorphism $Rj'_! \circ Rg_* \to Rf_* \circ Rj_!$
of functors $D^b_{\textit{Coh}}(\mathcal{O}_U) \to
\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)$ where
$Rj_!$ and $Rj'_!$ are as in Remark \ref{remark-extension-by-zero}.
\end{lemma}

\begin{proof}[First proof]
Let $K$ be an object of $D^b_{\textit{Coh}}(\mathcal{O}_U)$. Let $(K_n)$
be a Deligne system for $U \to X$ whose restriction to $U$ is constant
with value $K$. Of course this means that $(K_n)$ represents $Rj_!K$
in $\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_X)$. Observe that
both $Rj'_!Rg_*K$ and $Rf_*Rj_!K$ restrict to the constant pro-object with
value $Rg_*K$ on $V$. This is immediate for the first one and for the second
one it follows from the fact that $(Rf_*K_n)|_V = Rg_*(K_n|_U) = Rg_*K$.
By the uniqueness of Deligne systems in Lemma \ref{lemma-extension-by-zero}
it suffices to show that $(Rf_*K_n)$ is pro-isomorphic to a
Deligne system. The lemma referenced will also show that the
isomorphism we obtain is functorial.

\medskip\noindent
Proof that $(Rf_*K_n)$ is pro-isomorphic to a Deligne system.
First, we observe that the question is independent of the choice
of the Deligne system $(K_n)$ corresponding to $K$ (by the aforementioned
uniqueness). By Lemmas \ref{lemma-extension-by-zero-triangle} and
\ref{lemma-deligne-system-2-out-of-3}
if we have a distinguished triangle
$$
K \to L \to M \to K[1]
$$
in $D^b_{\textit{Coh}}(\mathcal{O}_U)$ and the result holds for
$K$ and $M$, then the result holds for $L$. Using the distinguished
triangles of canonical truncations (Derived Categories, Remark
\ref{derived-remark-truncation-distinguished-triangle})
we reduce to the problem studied in the next paragraph.

\medskip\noindent
Let $\mathcal{F}$ be a coherent $\mathcal{O}_X$-module.
Let $\mathcal{J} \subset \mathcal{O}_Y$ be a quasi-coherent
sheaf of ideals cutting out $Y \setminus V$. Denote
$\mathcal{J}^n\mathcal{F}$ the image of
$f^*\mathcal{J}^n \otimes \mathcal{F} \to \mathcal{F}$.
We have to show that $(Rf_*(\mathcal{J}^n\mathcal{F}))$
is a Deligne system. By Lemma \ref{lemma-characterize-extension-by-zero}
the question is local on $Y$. Thus we may assume $Y = \Spec(A)$ is affine
and $\mathcal{J}$ corresponds to an ideal $I \subset A$. By
Lemma \ref{lemma-characterize-extension-by-zero-algebra}
it suffices to show that the inverse system of cohomology modules
$(H^p(X, I^n\mathcal{F}))$ is pro-isomorphic to the inverse system
$(I^n M)$ for some finite $A$-module $M$.
This is shown in Cohomology of Schemes, Lemma
\ref{coherent-lemma-cohomology-powers-ideal-application}.
\end{proof}

\begin{proof}[Second proof]
Let $K$ be an object of $D^b_{\textit{Coh}}(\mathcal{O}_U)$.
Let $L$ be an object of $D^b_{\textit{Coh}}(\mathcal{O}_Y)$.
We will construct a bijection
$$
\Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)}(Rj'_!Rg_*K, L)
\longrightarrow
\Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)}(Rf_*Rj_!K, L)
$$
functorial in $K$ and $L$. Fixing $K$ this will determine an isomorphism
of pro-objects
$Rf_*Rj_!K \to Rj'_!Rg_*K$
by Categories, Remark \ref{categories-remark-pro-category-copresheaves}
and varying $K$ we obtain that this determines
an isomorphism of functors. To actually produce the isomorphism we
use the sequence of functorial equalities
\begin{align*}
\Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)}(Rj'_!Rg_*K, L)
& =
\Hom_V(Rg_*K, L|_V) \\
& =
\Hom_U(K, g^!(L|_V)) \\
& =
\Hom_U(K, f^!L|_U)) \\
& =
\Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_X)}(Rj_!K, f^!L) \\
& =
\Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)}(Rf_*Rj_!K, L)
\end{align*}
The first equality is true by Lemma \ref{lemma-lift-map}.
The second equality is true because $g$ is proper (as the base change
of $f$ to $V$) and hence $g^!$ is the right adjoint of pushforward by
construction, see Section \ref{section-upper-shriek}.
The third equality holds as $g^!(L|_V) = f^!L|_U$ by
Lemma \ref{lemma-restrict-before-or-after}.
Since $f^!L$ is in $D^+_{\textit{Coh}}(\mathcal{O}_X)$ by
Lemma \ref{lemma-shriek-coherent} the fourth equality follows from 
Lemma \ref{lemma-lift-map-plus}. The fifth equality holds again
because $f^!$ is the right adjoint to $Rf_*$ as $f$ is proper.
\end{proof}

\begin{lemma}
\label{lemma-well-defined}
Let $j : U \to X$ be an open immersion of Noetherian schemes.
Let $j' : U \to X'$ be a compactification of $U$ over $X$ (see proof)
and denote $f : X' \to X$ the structure morphism.
Then we have a canonical isomorphism $Rj_! \to Rf_* \circ R(j')_!$
of functors $D^b_{\textit{Coh}}(\mathcal{O}_U) \to
\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_X)$ where
$Rj_!$ and $Rj'_!$ are as in Remark \ref{remark-extension-by-zero}.
\end{lemma}

\begin{proof}
The fact that $X'$ is a compactification of $U$ over $X$ means
precisely that $f : X' \to X$ is proper, that $j'$ is an open immersion,
and $j = f \circ j'$. See
More on Flatness, Section \ref{flat-section-compactify}.
If $j'(U) = f^{-1}(j(U))$, then the lemma follows immediately from
Lemma \ref{lemma-well-defined-pre}.
If $j'(U) \not = f^{-1}(j(U))$, then denote $X'' \subset X'$ the
scheme theoretic closure of $j' : U \to X'$ and denote
$j'' : U \to X''$ the corresponding open immersion.
Picture
$$
\xymatrix{
& & X'' \ar[d]^{f'} \\
& & X' \ar[d]^f \\
U \ar[rr]^j \ar[rru]^{j'} \ar[rruu]^{j''} & & X
}
$$
By
More on Flatness, Lemma \ref{flat-lemma-compactifications-cofiltered} part (c)
and the discussion above we have isomorphisms
$Rf'_* \circ Rj''_! = Rj'_!$ and $R(f \circ f')_* \circ Rj''_! = Rj_!$.
Since $R(f \circ f')_* = Rf_* \circ Rf'_*$ we conclude.
\end{proof}

\begin{remark}
\label{remark-covariance-open-j-lower-shriek}
Let $X \supset U \supset U'$ be open subschemes of a Noetherian scheme $X$.
Denote $j : U \to X$ and $j' : U' \to X$ the inclusion morphisms.
We claim there is a canonical map
$$
Rj'_!(K|_{U'}) \longrightarrow Rj_!K
$$
functorial for $K$ in $D^b_{\textit{Coh}}(\mathcal{O}_U)$. Namely, by
Lemma \ref{lemma-lift-map} we have for any $L$ in
$D^b_{\textit{Coh}}(\mathcal{O}_X)$ the map
\begin{align*}
\Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_X)}(Rj_!K, L)
& =
\Hom_U(K, L|_U) \\
& \to
\Hom_{U'}(K|_{U'}, L|_{U'}) \\
& =
\Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_X)}(Rj'_!(K|_{U'}), L)
\end{align*}
functorial in $L$ and $K'$. The functoriality in $L$ shows by
Categories, Remark \ref{categories-remark-pro-category-copresheaves}
that we obtain a canonical map $Rj'_!(K|_{U'}) \to Rj_!K$ which is
functorial in $K$ by the functoriality of the arrow above in $K$.

\medskip\noindent
Here is an explicit construction of this arrow. Namely, suppose
that $\mathcal{F}^\bullet$ is a bounded complex of coherent
$\mathcal{O}_X$-modules whose restriction to $U$ represents $K$
in the derived category. We have seen in the proof of
Lemma \ref{lemma-extension-by-zero}
that such a complex always exists. Let $\mathcal{I}$, resp.\ $\mathcal{I}'$
be a quasi-coherent sheaf of ideals on $X$ with
$V(\mathcal{I}) = X \setminus U$, resp.\ $V(\mathcal{I}') = X \setminus U'$.
After replacing $\mathcal{I}$ by $\mathcal{I} + \mathcal{I}'$
we may assume $\mathcal{I}' \subset \mathcal{I}$.
By construction $Rj_!K$, resp.\ $Rj'_!(K|_{U'})$ is represented by the
inverse system $(K_n)$, resp.\ $(K'_n)$ of $D^b_{\textit{Coh}}(\mathcal{O}_X)$
with
$$
K_n = \mathcal{I}^n\mathcal{F}^\bullet
\quad\text{resp.}\quad
K'_n = (\mathcal{I}')^n\mathcal{F}^\bullet
$$
Clearly the map constructed above is given by the maps
$K'_n \to K_n$ coming from the inclusions
$(\mathcal{I}')^n \subset \mathcal{I}^n$.
\end{remark}






\section{Compactly supported cohomology for coherent modules}
\label{section-compactly-supported}

\noindent
In Situation \ref{situation-shriek} given a morphism $f : X \to Y$
in $\textit{FTS}_S$, we will define a functor
$$
Rf_! : D^b_{\textit{Coh}}(\mathcal{O}_X)
\longrightarrow
\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)
$$
Namely, we choose a compactification $j : X \to \overline{X}$ over $Y$
which is possible by More on Flatness, Theorem \ref{flat-theorem-nagata} and
Lemma \ref{flat-lemma-compactifyable}. Denote
$\overline{f} : \overline{X} \to Y$ the structure morphism. Then we set
$$
Rf_!K  = R\overline{f}_* Rj_! K
$$
for $K \in D^b_{\textit{Coh}}(\mathcal{O}_X)$ where $Rj_!$ is
as in Remark \ref{remark-extension-by-zero}.

\begin{lemma}
\label{lemma-lower-shriek-well-defined}
The functor $Rf_!$ is, up to isomorphism, independent
of the choice of the compactification.
\end{lemma}

\noindent
In fact, the functor $Rf_!$ will be characterized as a ``left adjoint''
to $f^!$ which will determine it up to unique isomorphism.

\begin{proof}
Consider the category of compactifications of $X$ over $Y$, which is
cofiltered according to More on Flatness, Theorem \ref{flat-theorem-nagata} and
Lemmas \ref{flat-lemma-compactifications-cofiltered} and
\ref{flat-lemma-compactifyable}.
To every choice of a compactification
$$
j : X \to \overline{X},\quad \overline{f} : \overline{X} \to Y
$$
the construction above associates the functor $R\overline{f}_* \circ Rj_!$.
Suppose given a morphism $g : \overline{X}_1 \to \overline{X}_2$
between compactifications $j_i : X \to \overline{X}_i$ over $Y$.
Then we get an isomorphism
$$
R\overline{f}_{2, *} \circ Rj_{2, !} =
R\overline{f}_{2, *} \circ Rg_* \circ j_{1, !} =
R\overline{f}_{1, *} \circ Rj_{1, !}
$$
using Lemma \ref{lemma-well-defined} in the first equality. In this way
we see our functor is independent of the choice of compactification
up to isomorphism.
\end{proof}

\begin{proposition}
\label{proposition-duality-compactly-supported}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. Then the functors $Rf_!$ and $f^!$ are adjoint in
the following sense: for all $K \in D^b_{\textit{Coh}}(\mathcal{O}_X)$
and $L \in D^+_{\textit{Coh}}(\mathcal{O}_Y)$ we have
$$
\Hom_X(K, f^!L) =
\Hom_{\text{Pro-}D^+_{\textit{Coh}}(\mathcal{O}_Y)}(Rf_!K, L)
$$
bifunctorially in $K$ and $L$.
\end{proposition}

\begin{proof}
Choose a compactification $j : X \to \overline{X}$ over $Y$ and
denote $\overline{f} : \overline{X} \to Y$ the structure morphism.
Then we have
\begin{align*}
\Hom_X(K, f^!L)
& =
\Hom_X(K, j^*\overline{f}{}^!L) \\
& =
\Hom_{\text{Pro-}D^+_{\textit{Coh}}(\mathcal{O}_{\overline{X}})}
(Rj_!K, \overline{f}{}^!L) \\
& =
\Hom_{\text{Pro-}D^+_{\textit{Coh}}(\mathcal{O}_Y)}(Rf_*Rj_!K, L) \\
& =
\Hom_{\text{Pro-}D^+_{\textit{Coh}}(\mathcal{O}_Y)}(Rf_!K, L)
\end{align*}
The first equality follows immediately from the construction of $f^!$ in
Section \ref{section-upper-shriek}.
By Lemma \ref{lemma-shriek-coherent} we have $\overline{f}{}^!L$
in $D^+_{\textit{Coh}}(\mathcal{O}_{\overline{X}})$ hence the second
equality follows from Lemma \ref{lemma-lift-map-plus}.
Since $\overline{f}$ is proper the functor $\overline{f}{}^!$
is the right adjoint of pushforward by construction. This is
why we have the third equality.
The fourth equality holds because $Rf_! = Rf_* Rj_!$.
\end{proof}

\begin{lemma}
\label{lemma-compactly-supported-triangle}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$. Let
$$
K \to L \to M \to K[1]
$$
be a distinguished triangle of $D^b_{\textit{Coh}}(\mathcal{O}_X)$.
Then there exists an inverse system of distinguished triangles
$$
K_n \to L_n \to M_n \to K_n[1]
$$
in $D^b_{\textit{Coh}}(\mathcal{O}_Y)$ such that the pro-systems
$(K_n)$, $(L_n)$, and $(M_n)$ give $Rf_!K$, $Rf_!L$, and $Rf_!M$.
\end{lemma}

\begin{proof}
Choose a compactification $j : X \to \overline{X}$ over $Y$ and
denote $\overline{f} : \overline{X} \to Y$ the structure morphism.
Choose an inverse system of distinguished triangles
$$
\overline{K}_n \to \overline{L}_n \to \overline{M}_n \to \overline{K}_n[1]
$$
in $D^b_{\textit{Coh}}(\mathcal{O}_{\overline{X}})$ as in
Lemma \ref{lemma-extension-by-zero-triangle} corresponding to the
open immersion $j$ and the given distinguished triangle. Take
$K_n = R\overline{f}_*\overline{K}_n$
and similarly for $L_n$ and $M_n$. This works by the very definition
of $Rf_!$.
\end{proof}

\begin{remark}
\label{remark-compose-inverse-systems}
Let $\mathcal{C}$ be a category. Suppose given an inverse system
$$
\ldots \xrightarrow{\alpha_4} (M_{3, n}) \xrightarrow{\alpha_3} (M_{2, n})
\xrightarrow{\alpha_2} (M_{1, n})
$$
of inverse systems in the category of pro-objects of $\mathcal{C}$.
In other words, the arrows $\alpha_i$ are morphisms of pro-objects. By
Categories, Example \ref{categories-example-pro-morphism-inverse-systems}
we can represent each $\alpha_i$ by a pair $(m_i, a_i)$ where
$m_i : \mathbf{N} \to \mathbf{N}$ is an increasing function and
$a_{i, n} : M_{i, m_i(n)} \to M_{i - 1, n}$ is a morphism of $\mathcal{C}$
making the diagrams
$$
\xymatrix{
\ldots \ar[r] &
M_{i, m_i(3)} \ar[d]^{a_{i, 3}} \ar[r] &
M_{i, m_i(2)} \ar[d]^{a_{i, 2}} \ar[r] &
M_{i, m_i(1)} \ar[d]^{a_{i, 1}} \\
\ldots \ar[r] &
M_{i - 1, 3} \ar[r] &
M_{i - 1, 2} \ar[r] &
M_{i - 1, 1}
}
$$
commute. By replacing $m_i(n)$ by $\max(n, m_i(n))$ and adjusting
the morphisms $a_i(n)$ accordingly (as in the example referenced)
we may assume that $m_i(n) \geq n$. In this situation consider the
inverse system
$$
\ldots \to
M_{4, m_4(m_3(m_2(4)))} \to
M_{3, m_3(m_2(3))} \to
M_{2, m_2(2)} \to
M_{1, 1}
$$
with general term
$$
M_k = M_{k, m_k(m_{k - 1}(\ldots (m_2(k))\ldots))}
$$
For any object $N$ of $\mathcal{C}$ we have
$$
\colim_i \colim_n \Mor_\mathcal{C}(M_{i, n}, N) =
\colim_k \Mor_\mathcal{C}(M_k, N) 
$$
We omit the details. In other words, we see that the inverse system $(M_k)$
has the property
$$
\colim_i \Mor_{\text{Pro-}\mathcal{C}}((M_{i, n}), N) =
\Mor_{\text{Pro-}\mathcal{C}}((M_k), N)
$$
This property determines the inverse system $(M_k)$ up to pro-isomorphism
by the discussion in
Categories, Remark \ref{categories-remark-pro-category-copresheaves}.
In this way we can turn certain inverse systems in $\text{Pro-}\mathcal{C}$
into pro-objects with countable index categories.
\end{remark}

\begin{remark}
\label{remark-composition-lower-shriek}
In Situation \ref{situation-shriek} let $f : X \to Y$ and $g : Y \to Z$
be composable morphisms of $\textit{FTS}_S$. Let us define the composition
$$
Rg_! \circ Rf_! :
D^b_{\textit{Coh}}(\mathcal{O}_X)
\longrightarrow
\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Z)
$$
Namely, by the very construction of $Rf_!$
for $K$ in $D^b_{\textit{Coh}}(\mathcal{O}_X)$
the output $Rf_!K$ is the pro-isomorphism class
of an inverse system $(M_n)$ in $D^b_{\textit{Coh}}(\mathcal{O}_Y)$.
Then, since $Rg_!$ is constructed similarly, we see that
$$
\ldots \to Rg_!M_3 \to Rg_!M_2 \to Rg_!M_1
$$
is an inverse system of $\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)$.
By the discussion in Remark \ref{remark-compose-inverse-systems}
there is a unique pro-isomorphism class, which we will denote
$Rg_! Rf_! K$, of inverse systems in $D^b_{\textit{Coh}}(\mathcal{O}_Z)$
such that
$$
\Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Z)}(Rg_!Rf_!K, L) =
\colim_n \Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Z)}(Rg_!M_n, L)
$$
We omit the discussion necessary to see that this construction
is functorial in $K$ as it will immediately follow from the next lemma.
\end{remark}

\begin{lemma}
\label{lemma-composition-lower-shriek}
In Situation \ref{situation-shriek} let $f : X \to Y$ and $g : Y \to Z$
be composable morphisms of $\textit{FTS}_S$. With notation as in
Remark \ref{remark-composition-lower-shriek} we have
$Rg_! \circ Rf_! = R(g \circ f)_!$.
\end{lemma}

\begin{proof}
By the discussion in
Categories, Remark \ref{categories-remark-pro-category-copresheaves}
it suffices to show that we obtain the same answer if we compute
$\Hom$ into $L$ in $D^b_{\textit{Coh}}(\mathcal{O}_Z)$. To do this
we compute, using the notation in
Remark \ref{remark-composition-lower-shriek}, as follows
\begin{align*}
\Hom_Z(Rg_!Rf_!K, L)
& =
\colim_n \Hom_Z(Rg_!M_n, L) \\
& =
\colim_n \Hom_Y(M_n, g^!L) \\
& =
\Hom_Y(Rf_!K, g^!L) \\
& =
\Hom_X(K, f^!g^!L) \\
& =
\Hom_X(K, (g \circ f)^!L) \\
& =
\Hom_Z(R(g \circ f)_!K, L)
\end{align*}
The first equality is the definition of $Rg_!Rf_!K$. The second
equality is Proposition \ref{proposition-duality-compactly-supported}
for $g$.
The third equality is the fact that $Rf_!K$ is given by $(M_n)$.
The fourth equality is
Proposition \ref{proposition-duality-compactly-supported} for $f$.
The fifth equality is Lemma \ref{lemma-upper-shriek-composition}.
The sixth is 
Proposition \ref{proposition-duality-compactly-supported} for $g \circ f$.
\end{proof}

\begin{remark}
\label{remark-covariance-open-lower-shriek}
In Situation \ref{situation-shriek} let $f : X \to Y$ be a morphism of
$\textit{FTS}_S$ and let $U \subset X$ be an open. Set
$g = f|_U : U \to Y$. Then there is a canonical morphism
$$
Rg_!(K|_U) \longrightarrow Rf_!K
$$
functorial in $K$ in $D^b_{\textit{Coh}}(\mathcal{O}_X)$
which can be defined in at least 3 ways.
\begin{enumerate}
\item Denote $i : U \to X$ the inclusion morphism. We have
$Rg_! = Rf_! \circ Ri_!$ by
Lemma \ref{lemma-composition-lower-shriek}
and we can use $Rf_!$ applied to the map $Ri_!(K|_U) \to K$
which is a special case of
Remark \ref{remark-covariance-open-j-lower-shriek}.
\item Choose a compactification $j : X \to \overline{X}$
of $X$ over $Y$ with structure morphism $\overline{f} : \overline{X} \to Y$.
Set $j' = j \circ i : U \to \overline{X}$. We can
use that $Rf_! = R\overline{f}_* \circ Rj_!$ and
$Rg_! = R\overline{f}_* \circ Rj'_!$
and we can use $R\overline{f}_*$ applied to the map
$Rj'_!(K|_U) \to Rj_!K$ of
Remark \ref{remark-covariance-open-j-lower-shriek}.
\item We can use
\begin{align*}
\Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)}(Rf_!K, L)
& =
\Hom_X(K, f^!L) \\
& \to
\Hom_U(K|_U, f^!L|_U) \\
& =
\Hom_U(K|_U, g^!L) \\
& =
\Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)}(Rg_!(K|_U), L)
\end{align*}
functorial in $L$ and $K$. Here we have used
Proposition \ref{proposition-duality-compactly-supported}
twice and the construction of upper shriek functors which
shows that $g^! = i^* \circ f^!$. The functoriality in $L$ shows by
Categories, Remark \ref{categories-remark-pro-category-copresheaves}
that we obtain a canonical map $Rg_!(K|_U) \to Rf_!K$ in
$\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)$ which is
functorial in $K$ by the functoriality of the arrow above in $K$.
\end{enumerate}
Each of these three constructions gives the same arrow; we omit the
details.
\end{remark}

\begin{remark}
\label{remark-covariance-etale-lower-shriek}
Let us generalize the covariance of compactly supported cohomology
given in Remark \ref{remark-covariance-open-lower-shriek}
to \'etale morphisms. Namely, in Situation \ref{situation-shriek}
suppose given a commutative diagram
$$
\xymatrix{
U \ar[rr]_h \ar[rd]_g & & X \ar[ld]^f \\
& Y
}
$$
of $\textit{FTS}_S$ with $h$ \'etale. Then there is a canonical morphism
$$
Rg_!(h^*K) \longrightarrow Rf_!K
$$
functorial in $K$ in $D^b_{\textit{Coh}}(\mathcal{O}_X)$. We define
this transformation using the sequence of maps
\begin{align*}
\Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)}(Rf_!K, L)
& =
\Hom_X(K, f^!L) \\
& \to
\Hom_U(h^*K, h^*(f^!L)) \\
& =
\Hom_U(h^*K, h^!f^!L) \\
& =
\Hom_U(h^*K, g^!L) \\
& =
\Hom_{\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)}(Rg_!(h^*K), L)
\end{align*}
functorial in $L$ and $K$. Here we have used
Proposition \ref{proposition-duality-compactly-supported}
twice, we have used the equality $h^* = h^!$ of
Lemma \ref{lemma-shriek-etale}, and we have used the equality
$h^! \circ f^! = g^!$ of Lemma \ref{lemma-upper-shriek-composition}.
The functoriality in $L$ shows by
Categories, Remark \ref{categories-remark-pro-category-copresheaves}
that we obtain a canonical map $Rg_!(h^*K) \to Rf_!K$ in
$\text{Pro-}D^b_{\textit{Coh}}(\mathcal{O}_Y)$ which is
functorial in $K$ by the functoriality of the arrow above in $K$.
\end{remark}

\begin{remark}
\label{remark-covariance-lower-shriek}
In Remarks \ref{remark-covariance-open-lower-shriek} and
\ref{remark-covariance-etale-lower-shriek} we have seen
that the construction of compactly supported cohomology is
covariant with respect to open immersions and \'etale morphisms.
In fact, the correct generality is that given a commutative diagram
$$
\xymatrix{
U \ar[rr]_h \ar[rd]_g & & X \ar[ld]^f \\
& Y
}
$$
of $\textit{FTS}_S$ with $h$ flat and quasi-finite there exists a
canonical transformation
$$
Rg_! \circ h^* \longrightarrow Rf_!
$$
As in Remark \ref{remark-covariance-etale-lower-shriek}
this map can be constructed using a transformation of functors
$h^* \to h^!$ on $D^+_{\textit{Coh}}(\mathcal{O}_X)$. Recall that
$h^!K = h^*K \otimes \omega_{U/X}$ where $\omega_{U/X} = h^!\mathcal{O}_X$
is the relative dualizing sheaf of the flat quasi-finite morphism $h$ (see
Lemmas \ref{lemma-perfect-comparison-shriek} and
\ref{lemma-flat-quasi-finite-shriek}).
Recall that $\omega_{U/X}$ is the same as the relative dualizing
module which will be constructed in Discriminants, Remark
\ref{discriminant-remark-relative-dualizing-for-quasi-finite}
by
Discriminants, Lemma \ref{discriminant-lemma-compare-dualizing}.
Thus we can use the trace element
$\tau_{U/X} : \mathcal{O}_U \to \omega_{U/X}$
which will be constructed in Discriminants, Remark
\ref{discriminant-remark-relative-dualizing-for-flat-quasi-finite}
to define our transformation.
If we ever need this, we will precisely formulate
and prove the result here.
\end{remark}







\section{Duality for compactly supported cohomology}
\label{section-duality-compactly-supported}

\noindent
Let $k$ be a field. Let $U$ be a separated scheme of finite type over $k$.
Let $K$ be an object of $D^b_{\textit{Coh}}(\mathcal{O}_U)$. Let us define
the compactly supported cohomology $H^i_c(U, K)$ of $K$ as follows.
Choose an open immersion $j : U \to X$ into a scheme proper over $k$
and a Deligne system $(K_n)$ for $j : U \to X$ whose restriction
to $U$ is constant with value $K$. Then we set
$$
H^i_c(U, K) = \lim H^i(X, K_n)
$$
We view this as a topological $k$-vector space using the limit topology
(see More on Algebra, Section \ref{more-algebra-section-topological-ring}).
There are several points to make here.

\medskip\noindent
First, this definition is independent of the choice of $X$ and $(K_n)$.
Namely, if $p : U \to \Spec(k)$ denotes the structure morphism, then
we already know that $Rp_!K = (R\Gamma(X, K_n))$
is well defined up to pro-isomorphism in $D(k)$ hence so is the limit
defining $H^i_c(U, K)$.

\medskip\noindent
Second, it may seem more natural to use the expression
$$
H^i(R\lim R\Gamma(X, K_n)) = R\Gamma(X, R\lim K_n)
$$
but this would give the same answer: since the $k$-vector spaces
$H^j(X, K_n)$ are finite dimensional, these inverse systems satisfy
Mittag-Leffler and hence $R^1\lim$ terms of Cohomology, Lemma
\ref{cohomology-lemma-RGamma-commutes-with-Rlim} vanish.

\medskip\noindent
If $U' \subset U$ is an open subscheme, then there is a canonical map
$$
H^i_c(U', K|_{U'}) \longrightarrow H^i_c(U, K)
$$
functorial for $K$ in $D^b_{\textit{Coh}}(\mathcal{O}_U)$.
See for example Remark \ref{remark-covariance-open-lower-shriek}.
In fact, using Remark \ref{remark-covariance-etale-lower-shriek}
we see that more generally such a map exists for an \'etale morphism
$U' \to U$ of separated schemes of finite type over $k$.

\medskip\noindent
If $V$ is a $k$-vector space then we put a topology on $\Hom_k(V, k)$
as follows: write $V = \bigcup V_i$ as the filtered union of its finite
dimensional $k$-subvector spaces and use the limit topology on
$\Hom_k(V, k) = \lim \Hom_k(V_i, k)$. If $\dim_k V < \infty$ then
the topology on $\Hom_k(V, k)$ is discrete. More generally, if
$V = \colim_n V_n$ is written as a directed colimit of finite dimensional
vector spaces, then $\Hom_k(V, k) = \lim \Hom_k(V_n, k)$ as topological
vector spaces.

\begin{lemma}
\label{lemma-duality-compact-support}
Let $p : U \to \Spec(k)$ be separated of finite type where $k$ is a field.
Let $\omega_{U/k}^\bullet = p^!\mathcal{O}_{\Spec(k)}$.
There are canonical isomorphisms
$$
\Hom_k(H^i(U, K), k) =
H^{-i}_c(U, R\SheafHom_{\mathcal{O}_U}(K, \omega_{U/k}^\bullet))
$$
of topological $k$-vector spaces
functorial for $K$ in $D^b_{\textit{Coh}}(\mathcal{O}_U)$.
\end{lemma}

\begin{proof}
Choose a compactification $j : U \to X$ over $k$. Let
$\mathcal{I} \subset \mathcal{O}_X$ be a quasi-coherent ideal
sheaf with $V(\mathcal{I}) = X \setminus U$.
By Derived Categories of Schemes, Proposition \ref{perfect-proposition-DCoh}
we may choose $M \in D^b_{\textit{Coh}}(\mathcal{O}_X)$
with $K = M|_U$. We have
$$
H^i(U, K) =
\Ext^i_U(\mathcal{O}_U, M|_U) =
\colim \Ext^i_X(\mathcal{I}^n, M) =
\colim H^i(X, R\SheafHom_{\mathcal{O}_X}(\mathcal{I}^n, M))
$$
by Lemma \ref{lemma-lift-map}.
Since $\mathcal{I}^n$ is a coherent $\mathcal{O}_X$-module,
we have $\mathcal{I}^n$ in $D^-_{\textit{Coh}}(\mathcal{O}_X)$,
hence $R\SheafHom_{\mathcal{O}_X}(\mathcal{I}^n, M)$ is in
$D^+_{\textit{Coh}}(\mathcal{O}_X)$ by
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-coherent-internal-hom}.

\medskip\noindent
Let $\omega_{X/k}^\bullet = q^!\mathcal{O}_{\Spec(k)}$ where
$q : X \to \Spec(k)$ is the structure morphism, see
Section \ref{section-duality-proper-over-field}. We find that
\begin{align*}
\Hom_k(
&
H^i(X, R\SheafHom_{\mathcal{O}_X}(\mathcal{I}^n, M)), k) \\
& =
\Ext^{-i}_X(R\SheafHom_{\mathcal{O}_X}(\mathcal{I}^n, M),
\omega_{X/k}^\bullet) \\
& =
H^{-i}(X, R\SheafHom_{\mathcal{O}_X}(R\SheafHom_{\mathcal{O}_X}(
\mathcal{I}^n, M), \omega_{X/k}^\bullet))
\end{align*}
by Lemma \ref{lemma-duality-proper-over-field}. By
Lemma \ref{lemma-internal-hom-evaluate-isom} part (1) the canonical map
$$
R\SheafHom_{\mathcal{O}_X}(M, \omega_{X/k}^\bullet)
\otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{I}^n
\longrightarrow
R\SheafHom_{\mathcal{O}_X}(R\SheafHom_{\mathcal{O}_X}(
\mathcal{I}^n, M), \omega_{X/k}^\bullet)
$$
is an isomorphism. Observe that
$\omega^\bullet_{U/k} = \omega^\bullet_{X/k}|_U$
because $p^!$ is constructed as $q^!$ composed with restriction to $U$.
Hence $R\SheafHom_{\mathcal{O}_X}(M, \omega_{X/k}^\bullet)$ is
an object of $D^b_{\textit{Coh}}(\mathcal{O}_X)$ which restricts
to $R\SheafHom_{\mathcal{O}_U}(K, \omega_{U/k}^\bullet)$ on $U$.
Hence by Lemma \ref{lemma-tensoring-Deligne-system} we conclude that
$$
\lim H^{-i}(X, R\SheafHom_{\mathcal{O}_X}(M, \omega_{X/k}^\bullet)
\otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{I}^n)
$$
is an avatar for the right hand side of the equality of the lemma.
Combining all the isomorphisms obtained in this manner we get
the isomorphism of the lemma.
\end{proof}

\begin{lemma}
\label{lemma-duality-compact-support-restrict-open}
With notation as in Lemma \ref{lemma-duality-compact-support}
suppose $U' \subset U$ is an open subscheme. Then the diagram
$$
\xymatrix{
\Hom_k(H^i(U, K), k) \ar[rr] & &
H^{-i}_c(U, R\SheafHom_{\mathcal{O}_U}(K, \omega_{U/k}^\bullet)) \\
\Hom_k(H^i(U', K|_{U'}), k) \ar[rr] \ar[u] & &
H^{-i}_c(U', R\SheafHom_{\mathcal{O}_{U'}}(K, \omega_{U'/k}^\bullet)) \ar[u]
}
$$
is commutative. Here the horizontal arrows are the isomorphisms of
Lemma \ref{lemma-duality-compact-support}, the vertical arrow on the
left is the contragredient to the restriction map
$H^i(U, K) \to H^i(U', K|_{U'})$, and the right vertical arrow
is Remark \ref{remark-covariance-open-lower-shriek} (see discussion
before the lemma).
\end{lemma}

\begin{proof}
We strongly urge the reader to skip this proof. Choose $X$ and $M$ as
in the proof of Lemma \ref{lemma-duality-compact-support}. We are going to drop
the subscript $\mathcal{O}_X$ from $R\SheafHom$ and $\otimes^\mathbf{L}$.
We write
$$
H^i(U, K) = \colim H^i(X, R\SheafHom(\mathcal{I}^n, M))
$$
and
$$
H^i(U', K|_{U'}) = \colim H^i(X, R\SheafHom((\mathcal{I}')^n, M))
$$
as in the proof of Lemma \ref{lemma-duality-compact-support} where we choose
$\mathcal{I}' \subset \mathcal{I}$ as in the discussion in
Remark \ref{remark-covariance-open-j-lower-shriek} so that the map
$H^i(U, K) \to H^i(U', K|_{U'})$ is induced by the maps
$(\mathcal{I}')^n \to \mathcal{I}^n$.
We similarly write
$$
H^i_c(U, R\SheafHom(K, \omega_{U/k}^\bullet)) =
\lim H^i(X,  R\SheafHom(M, \omega_{X/k}^\bullet)
\otimes^\mathbf{L} \mathcal{I}^n)
$$
and
$$
H^i_c(U', R\SheafHom(K|_{U'}, \omega_{U'/k}^\bullet)) =
\lim H^i(X,  R\SheafHom(M, \omega_{X/k}^\bullet)
\otimes^\mathbf{L} (\mathcal{I}')^n)
$$
so that the arrow $H^i_c(U', R\SheafHom(K|_{U'}, \omega_{U'/k}^\bullet))
\to H^i_c(U, R\SheafHom(K, \omega_{U/k}^\bullet))$ is similarly
deduced from the maps $(\mathcal{I}')^n \to \mathcal{I}^n$.
The diagrams
$$
\xymatrix{
R\SheafHom(M, \omega_{X/k}^\bullet)
\otimes^\mathbf{L} \mathcal{I}^n
\ar[rr] & &
R\SheafHom(R\SheafHom(\mathcal{I}^n, M), \omega_{X/k}^\bullet) \\
R\SheafHom(M, \omega_{X/k}^\bullet) \otimes^\mathbf{L} (\mathcal{I}')^n
\ar[rr] \ar[u] & &
R\SheafHom(R\SheafHom((\mathcal{I}')^n, M), \omega_{X/k}^\bullet) \ar[u]
}
$$
commute because the construction of the horizontal arrows in
Cohomology, Lemma \ref{cohomology-lemma-internal-hom-evaluate}
is functorial in all three entries. Hence we finally come down
to the assertion that the diagrams
$$
\xymatrix{
\Hom_k(H^i(X, R\SheafHom(\mathcal{I}^n, M)), k) \ar[r] &
H^{-i}(X, R\SheafHom(R\SheafHom(
\mathcal{I}^n, M), \omega_{X/k}^\bullet)) \\
\Hom_k(H^i(X, R\SheafHom((\mathcal{I}')^n, M)), k) \ar[r] \ar[u] &
H^{-i}(X, R\SheafHom(R\SheafHom(
(\mathcal{I}')^n, M), \omega_{X/k}^\bullet)) \ar[u]
}
$$
commute. This is true because the duality isomorphism
$$
\Hom_k(H^i(X, L), k) = \Ext^{-i}_X(L, \omega_{X/k}^\bullet) =
H^{-i}(X, R\SheafHom(L, \omega_{X/k}^\bullet))
$$
is functorial for $L$ in $D_\QCoh(\mathcal{O}_X)$.
\end{proof}

\begin{lemma}
\label{lemma-h0-compactly-supported}
Let $X$ be a proper scheme over a field $k$. Let
$K \in D^b_{\textit{Coh}}(\mathcal{O}_X)$ with $H^i(K) = 0$
for $i < 0$. Set $\mathcal{F} = H^0(K)$.
Let $Z \subset X$ be closed with complement $U = X \setminus U$.
Then
$$
H^0_c(U, K|_U) \subset H^0(X, \mathcal{F})
$$
is given by those global sections of $\mathcal{F}$ which
vanish in an open neighbourhood of $Z$.
\end{lemma}

\begin{proof}
Consider the map
$H^0_c(U, K|_U) \to H^0_X(X, K) = H^0(X, K) = H^0(X, \mathcal{F})$ of
Remark \ref{remark-covariance-open-lower-shriek}. To study this
we represent $K$ by a bounded complex $\mathcal{F}^\bullet$ with
$\mathcal{F}^i = 0$ for $i < 0$. Then we have by definition
$$
H^0_c(U, K|_U) = \lim H^0(X, \mathcal{I}^n\mathcal{F}^\bullet)
= \lim \Ker(
H^0(X, \mathcal{I}^n\mathcal{F}^0) \to
H^0(X, \mathcal{I}^n\mathcal{F}^1))
$$
By Artin-Rees (Cohomology of Schemes, Lemma \ref{coherent-lemma-Artin-Rees})
this is the same as $\lim H^0(X, \mathcal{I}^n\mathcal{F})$.
Thus the arrow $H^0_c(U, K|_U) \to H^0(X, \mathcal{F})$
is injective and the image consists of those global sections of $\mathcal{F}$
which are contained in the subsheaf $\mathcal{I}^n\mathcal{F}$
for any $n$. The characterization of these as the sections which
vanish in a neighbourhood of $Z$ comes from Krull's intersection
theorem (Algebra, Lemma \ref{algebra-lemma-intersect-powers-ideal-module-zero})
by looking at stalks of $\mathcal{F}$. See discussion in
Algebra, Remark \ref{algebra-remark-intersection-powers-ideal}
for the case of functions.
\end{proof}




\section{Lichtenbaum's theorem}
\label{section-lichtenbaum}

\noindent
The theorem below was conjectured by Lichtenbaum and proved by Grothendieck
(see \cite{Hartshorne-local-cohomology}). There is a very nice proof of the
theorem by Kleiman in \cite{Kleiman-Lichtenbaum}. A generalization of
the theorem to the case of cohomology with supports can be found in
\cite{Lyubeznik-Lichtenbaum}. The most interesting part of the argument
is contained in the proof of the following lemma.

\begin{lemma}
\label{lemma-lichtenbaum}
Let $U$ be a variety. Let $\mathcal{F}$ be a coherent $\mathcal{O}_U$-module.
If $H^d(U, \mathcal{F})$ is nonzero, then $\dim(U) \geq d$ and if
equality holds, then $U$ is proper.
\end{lemma}

\begin{proof}
By the Grothendieck's vanishing result in
Cohomology, Proposition \ref{cohomology-proposition-vanishing-Noetherian}
we conclude that $\dim(U) \geq d$.
Assume $\dim(U) = d$. Choose a compactification $U \to X$
such that $U$ is dense in $X$. (This is possible by
More on Flatness, Theorem \ref{flat-theorem-nagata} and
Lemma \ref{flat-lemma-compactifyable}.) After replacing $X$ by its
reduction we find that $X$ is a proper variety of dimension $d$
and we see that $U$ is proper if and only if $U = X$.
Set $Z = X \setminus U$. We will show that $H^d(U, \mathcal{F})$
is zero if $Z$ is nonempty.

\medskip\noindent
Choose a coherent $\mathcal{O}_X$-module
$\mathcal{G}$ whose restriction to $U$ is $\mathcal{F}$, see
Properties, Lemma \ref{properties-lemma-lift-finite-presentation}.
Let $\omega_X^\bullet$ denote the dualizing complex of $X$ as in
Section \ref{section-duality-proper-over-field}.
Set $\omega_U^\bullet = \omega_X^\bullet|_U$.
Then $H^d(U, \mathcal{F})$ is dual to
$$
H^{-d}_c(U, R\SheafHom_{\mathcal{O}_U}(\mathcal{F}, \omega_U^\bullet))
$$
by Lemma \ref{lemma-duality-compact-support}. By
Lemma \ref{lemma-duality-proper-over-field} we see that
the cohomology sheaves of $\omega_X^\bullet$ vanish in degrees $< -d$
and $H^{-d}(\omega_X^\bullet) = \omega_X$ is a coherent
$\mathcal{O}_X$-module which is $(S_2)$ and whose support is $X$.
In particular, $\omega_X$ is torsion free, see
Divisors, Lemma \ref{divisors-lemma-torsion-free-finite-noetherian-domain}.
Thus we see that the cohomology sheaf
$$
H^{-d}(R\SheafHom_{\mathcal{O}_X}(\mathcal{G}, \omega_X^\bullet)) =
\SheafHom(\mathcal{G}, \omega_X)
$$
is torsion free, see
Divisors, Lemma \ref{divisors-lemma-hom-into-torsion-free}.
Consequently this sheaf has no nonzero sections vanishing
on any nonempty open of $X$ (those would be torsion sections).
Thus it follows from Lemma \ref{lemma-h0-compactly-supported} that
$H^{-d}_c(U, R\SheafHom_{\mathcal{O}_U}(\mathcal{F}, \omega_U^\bullet))$
is zero, and hence $H^d(U, \mathcal{F})$ is zero as desired.
\end{proof}

\begin{theorem}
\label{theorem-lichtenbaum}
Let $X$ be a nonempty separated scheme of finite type over a field $k$.
Let $d = \dim(X)$. The following are equivalent
\begin{enumerate}
\item $H^d(X, \mathcal{F}) = 0$ for all coherent $\mathcal{O}_X$-modules
$\mathcal{F}$ on $X$,
\item $H^d(X, \mathcal{F}) = 0$ for all quasi-coherent $\mathcal{O}_X$-modules
$\mathcal{F}$ on $X$, and
\item no irreducible component $X' \subset X$ of dimension $d$
is proper over $k$.
\end{enumerate}
\end{theorem}

\begin{proof}
Assume there exists an irreducible component $X' \subset X$ (which we view
as an integral closed subscheme) which is proper and has dimension $d$.
Let $\omega_{X'}$ be a dualizing module of $X'$ over $k$, see
Lemma \ref{lemma-duality-proper-over-field}. Then
$H^d(X', \omega_{X'})$ is nonzero as it is dual to $H^0(X', \mathcal{O}_{X'})$
by the lemma. Hence we see that $H^d(X, \omega_{X'}) = H^d(X', \omega_{X'})$
is nonzero and we conclude that (1) does not hold.
In this way we see that (1) implies (3).

\medskip\noindent
Let us prove that (3) implies (1).
Let $\mathcal{F}$ be a coherent $\mathcal{O}_X$-module such that
$H^d(X, \mathcal{F})$ is nonzero. Choose a filtration
$$
0 = \mathcal{F}_0 \subset \mathcal{F}_1 \subset
\ldots \subset \mathcal{F}_m = \mathcal{F}
$$
as in Cohomology of Schemes, Lemma \ref{coherent-lemma-coherent-filter}.
We obtain exact sequences
$$
H^d(X, \mathcal{F}_i) \to H^d(X, \mathcal{F}_{i + 1}) \to
H^d(X, \mathcal{F}_{i + 1}/\mathcal{F}_i)
$$
Thus for some $i \in \{1, \ldots, m\}$ we find that
$H^d(X, \mathcal{F}_{i + 1}/\mathcal{F}_i)$ is nonzero.
By our choice of the filtration this means that there exists
an integral closed subscheme $Z \subset X$
and a nonzero coherent sheaf of ideals $\mathcal{I} \subset \mathcal{O}_Z$
such that $H^d(Z, \mathcal{I})$ is nonzero.
By Lemma \ref{lemma-lichtenbaum}
we conclude $\dim(Z) = d$ and $Z$ is proper over $k$
contradicting (3). Hence (3) implies (1).

\medskip\noindent
Finally, let us show that (1) and (2) are equivalent for any Noetherian scheme
$X$. Namely, (2) trivially implies (1). On the other hand, assume (1) and
let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module. Then we can write
$\mathcal{F} = \colim \mathcal{F}_i$ as the filtered colimit of its coherent
submodules, see
Properties, Lemma \ref{properties-lemma-quasi-coherent-colimit-finite-type}.
Then we have $H^d(X, \mathcal{F}) = \colim H^d(X, \mathcal{F}_i) = 0$
by Cohomology, Lemma \ref{cohomology-lemma-quasi-separated-cohomology-colimit}.
Thus (2) is true.
\end{proof}






\input{chapters}

\bibliography{my}
\bibliographystyle{amsalpha}

\end{document}
